26#include "llvm/IR/IntrinsicsAMDGPU.h"
34#define GET_CALLING_CONV_IMPL
35#include "AMDGPUGenCallingConv.inc"
38 "amdgpu-bypass-slow-div",
39 cl::desc(
"Skip 64-bit divide for dynamic 32-bit values"),
48 if (StoreSize % 32 == 0)
211 {MVT::v2i8, MVT::v4i8, MVT::v2i16, MVT::v3i16, MVT::v4i16})
418 {MVT::f16, MVT::f32},
Legal);
424 {MVT::f16, MVT::f32, MVT::f64},
Expand);
451 {MVT::v2f32, MVT::v3f32, MVT::v4f32, MVT::v5f32,
452 MVT::v6f32, MVT::v7f32, MVT::v8f32, MVT::v16f32,
453 MVT::v2f64, MVT::v3f64, MVT::v4f64, MVT::v8f64,
461 {MVT::v3i32, MVT::v3f32, MVT::v4i32, MVT::v4f32,
462 MVT::v5i32, MVT::v5f32, MVT::v6i32, MVT::v6f32,
463 MVT::v7i32, MVT::v7f32, MVT::v8i32, MVT::v8f32,
464 MVT::v9i32, MVT::v9f32, MVT::v10i32, MVT::v10f32,
465 MVT::v11i32, MVT::v11f32, MVT::v12i32, MVT::v12f32},
470 {MVT::v2f32, MVT::v2i32, MVT::v3f32, MVT::v3i32, MVT::v4f32,
471 MVT::v4i32, MVT::v5f32, MVT::v5i32, MVT::v6f32, MVT::v6i32,
472 MVT::v7f32, MVT::v7i32, MVT::v8f32, MVT::v8i32, MVT::v9f32,
473 MVT::v9i32, MVT::v10i32, MVT::v10f32, MVT::v11i32, MVT::v11f32,
474 MVT::v12i32, MVT::v12f32, MVT::v16i32, MVT::v32f32, MVT::v32i32,
475 MVT::v2f64, MVT::v2i64, MVT::v3f64, MVT::v3i64, MVT::v4f64,
476 MVT::v4i64, MVT::v8f64, MVT::v8i64, MVT::v16f64, MVT::v16i64},
483 const MVT ScalarIntVTs[] = { MVT::i32, MVT::i64 };
484 for (
MVT VT : ScalarIntVTs) {
522 for (
auto VT : {MVT::i8, MVT::i16})
526 MVT::v2i32, MVT::v3i32, MVT::v4i32, MVT::v5i32, MVT::v6i32, MVT::v7i32,
527 MVT::v9i32, MVT::v10i32, MVT::v11i32, MVT::v12i32};
529 for (
MVT VT : VectorIntTypes) {
556 MVT::v2f32, MVT::v3f32, MVT::v4f32, MVT::v5f32, MVT::v6f32, MVT::v7f32,
557 MVT::v9f32, MVT::v10f32, MVT::v11f32, MVT::v12f32};
559 for (
MVT VT : FloatVectorTypes) {
680 case AMDGPUISD::RCP_LEGACY:
681 case AMDGPUISD::RCP_IFLAG:
682 case AMDGPUISD::SIN_HW:
683 case AMDGPUISD::FMUL_LEGACY:
684 case AMDGPUISD::FMIN_LEGACY:
685 case AMDGPUISD::FMAX_LEGACY:
686 case AMDGPUISD::FMED3:
697 unsigned Opc =
N->getOpcode();
718 return (
N->getNumOperands() > 2 &&
N->getOpcode() !=
ISD::SELECT) ||
727 return N->getValueType(0) == MVT::f32;
737 switch (
N->getOpcode()) {
743 case AMDGPUISD::DIV_SCALE:
752 switch (
N->getConstantOperandVal(0)) {
753 case Intrinsic::amdgcn_interp_p1:
754 case Intrinsic::amdgcn_interp_p2:
755 case Intrinsic::amdgcn_interp_mov:
756 case Intrinsic::amdgcn_interp_p1_f16:
757 case Intrinsic::amdgcn_interp_p2_f16:
777 unsigned NumMayIncreaseSize = 0;
778 MVT VT =
N->getValueType(0).getScalarType().getSimpleVT();
783 for (
const SDNode *U :
N->users()) {
818 bool ForCodeSize)
const {
825 return (ScalarVT != MVT::f32 && ScalarVT != MVT::f64);
830 std::optional<unsigned> ByteOffset)
const {
842 EVT OldVT =
N->getValueType(0);
857 if (OldSize >= 32 && NewSize < 32 && MN->
getAlign() >=
Align(4) &&
872 return (OldSize < 32);
887 if ((LScalarSize >= CastScalarSize) && (CastScalarSize < 32))
892 CastTy, MMO, &
Fast) &&
908 switch (
N->getOpcode()) {
913 unsigned IntrID =
N->getConstantOperandVal(0);
917 unsigned IntrID =
N->getConstantOperandVal(1);
925 case AMDGPUISD::SETCC:
935 switch (
Op.getOpcode()) {
943 case AMDGPUISD::RCP: {
945 EVT VT =
Op.getValueType();
951 return DAG.
getNode(AMDGPUISD::RCP, SL, VT, NegSrc,
Op->getFlags());
971 return VT == MVT::f32 || VT == MVT::f64 || VT == MVT::f16 || VT == MVT::bf16;
978 return VT == MVT::f32 || VT == MVT::f64 || VT == MVT::f16 || VT == MVT::bf16;
1002 unsigned SrcSize = Source.getSizeInBits();
1005 return DestSize < SrcSize && DestSize % 32 == 0 ;
1011 unsigned SrcSize = Source->getScalarSizeInBits();
1014 if (DestSize== 16 && Subtarget->has16BitInsts())
1015 return SrcSize >= 32;
1017 return DestSize < SrcSize && DestSize % 32 == 0;
1021 unsigned SrcSize = Src->getScalarSizeInBits();
1024 if (SrcSize == 16 && Subtarget->has16BitInsts())
1025 return DestSize >= 32;
1027 return SrcSize == 32 && DestSize == 64;
1036 if (Src == MVT::i16)
1037 return Dest == MVT::i32 ||Dest == MVT::i64 ;
1039 return Src == MVT::i32 && Dest == MVT::i64;
1044 switch (
N->getOpcode()) {
1067 if (!
N->isDivergent() && DestVT.
isInteger() &&
1095 "Expected shift op");
1097 SDValue ShiftLHS =
N->getOperand(0);
1112 if (
N->getValueType(0) == MVT::i32 &&
N->hasOneUse() &&
1113 (
N->user_begin()->getOpcode() ==
ISD::SRA ||
1114 N->user_begin()->getOpcode() ==
ISD::SRL))
1124 return LHS0 && LHS1 && RHSLd && LHS0->getExtensionType() ==
ISD::ZEXTLOAD &&
1125 LHS1->getAPIntValue() == LHS0->getMemoryVT().getScalarSizeInBits() &&
1128 SDValue LHS =
N->getOperand(0).getOperand(0);
1129 SDValue RHS =
N->getOperand(0).getOperand(1);
1130 return !(IsShiftAndLoad(LHS, RHS) || IsShiftAndLoad(RHS, LHS));
1150 return CC_AMDGPU_CS_CHAIN;
1154 return CC_AMDGPU_Func;
1180 return RetCC_SI_Shader;
1183 return RetCC_SI_Gfx;
1187 return RetCC_AMDGPU_Func;
1225 const unsigned ExplicitOffset = Subtarget->getExplicitKernelArgOffset();
1229 uint64_t ExplicitArgOffset = 0;
1232 unsigned InIndex = 0;
1235 const bool IsByRef = Arg.hasByRefAttr();
1236 Type *BaseArgTy = Arg.getType();
1237 Type *MemArgTy = IsByRef ? Arg.getParamByRefType() : BaseArgTy;
1238 Align Alignment =
DL.getValueOrABITypeAlignment(
1239 IsByRef ? Arg.getParamAlign() : std::nullopt, MemArgTy);
1240 MaxAlign = std::max(Alignment, MaxAlign);
1241 uint64_t AllocSize =
DL.getTypeAllocSize(MemArgTy);
1243 uint64_t ArgOffset =
alignTo(ExplicitArgOffset, Alignment) + ExplicitOffset;
1244 ExplicitArgOffset =
alignTo(ExplicitArgOffset, Alignment) + AllocSize;
1256 &Offsets, ArgOffset);
1258 for (
unsigned Value = 0, NumValues = ValueVTs.
size();
1260 uint64_t BasePartOffset = Offsets[
Value];
1296 }
else if (RegisterVT.
isVector()) {
1299 assert(MemoryBits % NumElements == 0);
1303 MemoryBits / NumElements);
1321 unsigned PartOffset = 0;
1322 for (
unsigned i = 0; i != NumRegs; ++i) {
1324 BasePartOffset + PartOffset,
1342 return DAG.
getNode(AMDGPUISD::ENDPGM,
DL, MVT::Other, Chain);
1363 int ClobberedFI)
const {
1366 int64_t LastByte = FirstByte + MFI.
getObjectSize(ClobberedFI) - 1;
1377 if (FI->getIndex() < 0) {
1379 int64_t InLastByte = InFirstByte;
1382 if ((InFirstByte <= FirstByte && FirstByte <= InLastByte) ||
1383 (FirstByte <= InFirstByte && InFirstByte <= LastByte))
1405 FuncName =
G->getSymbol();
1407 FuncName =
G->getGlobal()->getName();
1442 switch (
Op.getOpcode()) {
1446 "instruction is not implemented yet!");
1498 switch (
N->getOpcode()) {
1539 EVT VT =
Op.getValueType();
1558 Fn,
"unsupported use of BARRIER address space",
1568 if (std::optional<uint32_t>
Address =
1578 GV->
getName() !=
"llvm.amdgcn.module.lds") {
1582 Fn,
"local memory global used by non-kernel function",
1614 EVT VT =
Op.getValueType();
1616 unsigned OpBitSize =
Op.getOperand(0).getValueType().getSizeInBits();
1617 if (OpBitSize >= 32 && OpBitSize % 32 == 0) {
1618 unsigned NewNumElt = OpBitSize / 32;
1619 EVT NewEltVT = (NewNumElt == 1) ? MVT::i32
1621 MVT::i32, NewNumElt);
1622 for (
const SDUse &U :
Op->ops()) {
1628 Args.push_back(NewIn);
1632 NewNumElt *
Op.getNumOperands());
1638 for (
const SDUse &U :
Op->ops())
1648 unsigned Start =
Op.getConstantOperandVal(1);
1649 EVT VT =
Op.getValueType();
1650 EVT SrcVT =
Op.getOperand(0).getValueType();
1655 assert(NumElt % 2 == 0 && NumSrcElt % 2 == 0 &&
"expect legal types");
1659 EVT NewVT = NumElt == 2
1731 Opc = AMDGPUISD::FMIN_LEGACY;
1737 Opc = AMDGPUISD::FMIN_LEGACY;
1743 Opc = AMDGPUISD::FMAX_LEGACY;
1749 Opc = AMDGPUISD::FMAX_LEGACY;
1772 if ((LHS == True && RHS == False) || (LHS == False && RHS == True))
1792 if (LHS == NegTrue && CFalse && CRHS) {
1796 False, CC, Flags, DCI);
1806std::pair<SDValue, SDValue>
1818 return std::pair(
Lo,
Hi);
1847 HiVT = NumElts - LoNumElts == 1
1850 return std::pair(LoVT, HiVT);
1855std::pair<SDValue, SDValue>
1857 const EVT &LoVT,
const EVT &HiVT,
1859 EVT VT =
N.getValueType();
1863 "More vector elements requested than available!");
1894 EVT VT =
Op.getValueType();
1907 EVT MemVT =
Load->getMemoryVT();
1912 EVT LoMemVT, HiMemVT;
1924 Load->getExtensionType(), SL, LoVT,
Load->getChain(), BasePtr, SrcValue,
1925 LoMemVT, BaseAlign,
Load->getMemOperand()->getFlags(),
Load->getAAInfo());
1928 Load->getExtensionType(), SL, HiVT,
Load->getChain(), HiPtr,
1930 Load->getMemOperand()->getFlags(),
Load->getAAInfo());
1954 EVT VT =
Op.getValueType();
1956 EVT MemVT =
Load->getMemoryVT();
1964 if (NumElements != 3 ||
1965 (BaseAlign <
Align(8) &&
1969 assert(NumElements == 3);
1976 Load->getExtensionType(), SL, WideVT,
Load->getChain(), BasePtr, SrcValue,
1977 WideMemVT, BaseAlign,
Load->getMemOperand()->getFlags());
2002 EVT LoMemVT, HiMemVT;
2017 DAG.
getTruncStore(Chain, SL,
Lo, BasePtr, SrcValue, LoMemVT, BaseAlign,
2018 Store->getMemOperand()->getFlags(),
Store->getAAInfo());
2021 Store->getMemOperand()->getFlags(),
Store->getAAInfo());
2031 EVT VT =
Op.getValueType();
2032 assert(VT == MVT::i32 &&
"LowerDIVREMToFloat expects an i32");
2036 MVT IntVT = MVT::i32;
2037 MVT FltVT = MVT::f32;
2039 unsigned LHSSignBits;
2040 unsigned RHSSignBits;
2044 if (LHSSignBits < 9 || RHSSignBits < 9)
2055 unsigned SignBits = std::min(LHSSignBits, RHSSignBits);
2056 unsigned DivBits = BitSize - SignBits;
2065 if (DivBits > (Sign ? 23 : 22))
2098 fa, DAG.
getNode(AMDGPUISD::RCP,
DL, FltVT, fb));
2117 EVT VT =
Op.getValueType();
2119 assert(VT == MVT::i64 &&
"LowerUDIVREM64 expects an i64");
2129 std::tie(LHS_Lo, LHS_Hi) = DAG.
SplitScalar(LHS,
DL, HalfVT, HalfVT);
2133 std::tie(RHS_Lo, RHS_Hi) = DAG.
SplitScalar(RHS,
DL, HalfVT, HalfVT);
2192 std::tie(Mulhi1_Lo, Mulhi1_Hi) =
2205 std::tie(Mulhi2_Lo, Mulhi2_Hi) =
2219 std::tie(Mul3_Lo, Mul3_Hi) = DAG.
SplitScalar(Mul3,
DL, HalfVT, HalfVT);
2298 for (
unsigned i = 0; i < halfBitWidth; ++i) {
2299 const unsigned bitPos = halfBitWidth - i - 1;
2330 EVT VT =
Op.getValueType();
2332 if (VT == MVT::i64) {
2338 if (VT == MVT::i32) {
2385 EVT VT =
Op.getValueType();
2393 if (VT == MVT::i32) {
2472 const unsigned FractBits = 52;
2473 const unsigned ExpBits = 11;
2489 assert(
Op.getValueType() == MVT::f64);
2499 const unsigned FractBits = 52;
2511 = DAG.
getConstant((UINT64_C(1) << FractBits) - 1, SL, MVT::i64);
2536 assert(
Op.getValueType() == MVT::f64);
2569 auto VT =
Op.getValueType();
2570 auto Arg =
Op.getOperand(0u);
2582 EVT VT =
Op.getValueType();
2633 switch (Src.getOpcode()) {
2635 return Src.getOperand(0).getValueType() == MVT::f16;
2639 case AMDGPUISD::LOG:
2640 case AMDGPUISD::EXP:
2643 unsigned IntrinsicID = Src.getConstantOperandVal(0);
2644 switch (IntrinsicID) {
2645 case Intrinsic::amdgcn_frexp_mant:
2646 case Intrinsic::amdgcn_log:
2647 case Intrinsic::amdgcn_log_clamp:
2648 case Intrinsic::amdgcn_exp2:
2649 case Intrinsic::amdgcn_sqrt:
2664 return Flags.hasApproximateFuncs();
2680 EVT VT = Src.getValueType();
2691 return IsLtSmallestNormal;
2697 EVT VT = Src.getValueType();
2710std::pair<SDValue, SDValue>
2731 return {ScaledInput, IsLtSmallestNormal};
2742 EVT VT =
Op.getValueType();
2746 if (VT == MVT::f16) {
2750 SDValue Log = DAG.
getNode(AMDGPUISD::LOG, SL, MVT::f32, Ext, Flags);
2755 auto [ScaledInput, IsLtSmallestNormal] =
2758 return DAG.
getNode(AMDGPUISD::LOG, SL, VT, Src, Flags);
2778 EVT VT =
Op.getValueType();
2784 if (VT == MVT::f16 || Flags.hasApproximateFuncs()) {
2788 bool PromoteToF32 = VT == MVT::f16 && (!Flags.hasApproximateFuncs() ||
2805 SDValue ScaledInput, IsScaled;
2817 if (Subtarget->hasFastFMAF32()) {
2819 const float c_log10 = 0x1.344134p-2f;
2820 const float cc_log10 = 0x1.09f79ep-26f;
2823 const float c_log = 0x1.62e42ep-1f;
2824 const float cc_log = 0x1.efa39ep-25f;
2830 Flags.setAllowContract(
false);
2838 const float ch_log10 = 0x1.344000p-2f;
2839 const float ct_log10 = 0x1.3509f6p-18f;
2842 const float ch_log = 0x1.62e000p-1f;
2843 const float ct_log = 0x1.0bfbe8p-15f;
2855 Flags.setAllowContract(
false);
2862 const bool IsFiniteOnly = Flags.hasNoNaNs() && Flags.hasNoInfs();
2865 if (!IsFiniteOnly) {
2891 EVT VT = Src.getValueType();
2895 double Log2BaseInverted =
2898 if (VT == MVT::f32) {
2901 SDValue LogSrc = DAG.
getNode(AMDGPUISD::LOG, SL, VT, ScaledInput, Flags);
2908 ScaledResultOffset, Zero, Flags);
2912 if (Subtarget->hasFastFMAF32())
2923 return DAG.
getNode(
ISD::FMUL, SL, VT, Log2Operand, Log2BaseInvertedOperand,
3020 if (!Flags.hasNoInfs()) {
3023 Z = DAG.
getSelect(
DL, MVT::f64, CondHi, Z, PInf, Flags);
3029 Z = DAG.
getSelect(
DL, MVT::f64, CondLo, Z, Zero, Flags);
3038 EVT VT =
Op.getValueType();
3046 if (VT == MVT::f16) {
3050 SDValue Log = DAG.
getNode(AMDGPUISD::EXP, SL, MVT::f32, Ext, Flags);
3058 return DAG.
getNode(AMDGPUISD::EXP, SL, MVT::f32, Src, Flags);
3078 SDValue Exp2 = DAG.
getNode(AMDGPUISD::EXP, SL, VT, AddInput, Flags);
3091 bool IsExp10)
const {
3094 EVT VT =
X.getValueType();
3099 return DAG.
getNode(VT == MVT::f32 ? (
unsigned)AMDGPUISD::EXP
3101 SL, VT,
Mul, Flags);
3107 EVT VT =
X.getValueType();
3126 SDValue Exp2 = DAG.
getNode(AMDGPUISD::EXP, SL, VT, ExpInput, Flags);
3141 const EVT VT =
X.getValueType();
3143 const unsigned Exp2Op = VT == MVT::f32 ?
static_cast<unsigned>(AMDGPUISD::EXP)
3193 EVT VT =
Op.getValueType();
3257 if (Subtarget->hasFastFMAF32()) {
3259 const float cc_exp = 0x1.4ae0bep-26f;
3260 const float c_exp10 = 0x1.a934f0p+1f;
3261 const float cc_exp10 = 0x1.2f346ep-24f;
3271 const float ch_exp = 0x1.714000p+0f;
3272 const float cl_exp = 0x1.47652ap-12f;
3274 const float ch_exp10 = 0x1.a92000p+1f;
3275 const float cl_exp10 = 0x1.4f0978p-11f;
3290 PL =
getMad(DAG, SL, VT, XH, CL, Mad0, Flags);
3305 DAG.
getConstantFP(IsExp10 ? -0x1.66d3e8p+5f : -0x1.9d1da0p+6f, SL, VT);
3314 if (!Flags.hasNoInfs()) {
3316 DAG.
getConstantFP(IsExp10 ? 0x1.344136p+5f : 0x1.62e430p+6f, SL, VT);
3331 EVT VT =
Op.getValueType();
3348 DAG.
getNode(AMDGPUISD::FMUL_LEGACY, SL, VT,
Y, Log, CoreFlags);
3349 return DAG.
getNode(AMDGPUISD::EXP, SL, VT,
Mul, CoreFlags);
3377 if (Flags.hasNoNaNs())
3392 DAG.
getNOT(SL, YIsInt, SetCCVT));
3409 auto Opc =
Op.getOpcode();
3410 auto Arg =
Op.getOperand(0u);
3411 auto ResultVT =
Op.getValueType();
3413 if (ResultVT != MVT::i8 && ResultVT != MVT::i16)
3417 assert(ResultVT == Arg.getValueType());
3419 const uint64_t NumBits = ResultVT.getFixedSizeInBits();
3426 NewOp = DAG.
getNode(
Opc, SL, MVT::i32, NewOp);
3429 NewOp = DAG.
getNode(
Opc, SL, MVT::i32, NewOp);
3442 unsigned NewOpc = Ctlz ? AMDGPUISD::FFBH_U32 : AMDGPUISD::FFBL_B32;
3446 bool Is64BitScalar = !Src->isDivergent() && Src.getValueType() == MVT::i64;
3448 if (Src.getValueType() == MVT::i32 || Is64BitScalar) {
3462 Op.getValueType().getScalarSizeInBits(), SL, MVT::i32);
3482 OprLo = DAG.
getNode(AddOpc, SL, MVT::i32, OprLo, Const32);
3484 OprHi = DAG.
getNode(AddOpc, SL, MVT::i32, OprHi, Const32);
3499 assert(Src.getValueType() == MVT::i32 &&
"LowerCTLS only supports i32");
3511 assert(FP16Ty == MVT::f16 || FP16Ty == MVT::bf16);
3554 if (
Signed && Subtarget->isGCN()) {
3669 EVT DestVT =
Op.getValueType();
3671 EVT SrcVT = Src.getValueType();
3675 if (SrcVT == MVT::i16) {
3676 if (DestVT == MVT::f16)
3681 return DAG.
getNode(CvtOpc,
DL, DestVT, Ext);
3684 if (DestVT == MVT::bf16 || DestVT == MVT::f16)
3687 if (SrcVT != MVT::i64)
3690 if (DestVT == MVT::f32)
3693 assert(DestVT == MVT::f64);
3712 EVT SrcVT = Src.getValueType();
3714 assert(SrcVT == MVT::f32 || SrcVT == MVT::f64);
3727 if (
Signed && SrcVT == MVT::f32) {
3740 if (SrcVT == MVT::f64) {
3762 SL, MVT::i32, FloorMul);
3768 if (
Signed && SrcVT == MVT::f32) {
3788 return DAG.
getNode(AMDGPUISD::FP_TO_FP16,
DL,
Op.getValueType(), N0);
3790 if (
Op->getFlags().hasApproximateFuncs()) {
3801 assert(Src.getSimpleValueType() == MVT::f64);
3805 const unsigned ExpMask = 0x7ff;
3806 const unsigned ExpBiasf64 = 1023;
3807 const unsigned ExpBiasf16 = 15;
3890 unsigned OpOpcode =
Op.getOpcode();
3891 EVT SrcVT = Src.getValueType();
3892 EVT DestVT =
Op.getValueType();
3895 if (SrcVT == MVT::f16 && DestVT == MVT::i16)
3898 if (SrcVT == MVT::bf16 || (SrcVT == MVT::f16 && DestVT == MVT::i32)) {
3901 return DAG.
getNode(
Op.getOpcode(),
DL, DestVT, PromotedSrc);
3905 if (DestVT == MVT::i16 && (SrcVT == MVT::f32 || SrcVT == MVT::f64)) {
3912 if (DestVT != MVT::i64)
3915 if (SrcVT == MVT::f16 ||
3922 return DAG.
getNode(Ext,
DL, MVT::i64, FpToInt32);
3925 if (SrcVT == MVT::f32 || SrcVT == MVT::f64)
3934 unsigned OpOpcode =
Op.getOpcode();
3935 EVT SrcVT = Src.getValueType();
3936 EVT DstVT =
Op.getValueType();
3937 SDValue SatVTOp =
Op.getNode()->getOperand(1);
3943 assert(SatWidth <= DstWidth &&
"Saturation width cannot exceed result width");
3947 if (SatWidth == DstWidth) {
3948 if ((DstVT == MVT::i32 && (SrcVT == MVT::f32 || SrcVT == MVT::f64)) ||
3949 (DstVT == MVT::i16 && (SrcVT == MVT::f16 || SrcVT == MVT::f32)) ||
3950 (DstVT == MVT::v2i16 && SrcVT == MVT::v2f32))
3959 if (SatWidth < DstWidth && SatWidth <= 32) {
3964 Subtarget->has16BitInsts() && SrcVT == MVT::f16 && SatWidth < 16
3998 if (DstVT == MVT::i64 &&
3999 (SrcVT == MVT::f16 || SrcVT == MVT::bf16 ||
4002 return DAG.
getNode(OpOpcode,
DL, DstVT, Src, Int32VTOp);
4006 if (DstVT == MVT::i32 && (SrcVT == MVT::f16 || SrcVT == MVT::bf16)) {
4008 return DAG.
getNode(
Op.getOpcode(),
DL, DstVT, PromotedSrc, SatVTOp);
4014 if (DstWidth < 32) {
4018 (DstWidth < 16 && Subtarget->has16BitInsts()) ? MVT::i16 : MVT::i32;
4031 MVT VT =
Op.getSimpleValueType();
4045 for (
unsigned I = 0;
I < NElts; ++
I)
4060 EVT VT =
Op.getValueType();
4074 unsigned NewOpcode = Node24->
getOpcode();
4078 case Intrinsic::amdgcn_mul_i24:
4079 NewOpcode = AMDGPUISD::MUL_I24;
4081 case Intrinsic::amdgcn_mul_u24:
4082 NewOpcode = AMDGPUISD::MUL_U24;
4084 case Intrinsic::amdgcn_mulhi_i24:
4085 NewOpcode = AMDGPUISD::MULHI_I24;
4087 case Intrinsic::amdgcn_mulhi_u24:
4088 NewOpcode = AMDGPUISD::MULHI_U24;
4102 if (DemandedLHS || DemandedRHS)
4104 DemandedLHS ? DemandedLHS :
LHS,
4105 DemandedRHS ? DemandedRHS :
RHS);
4117template <
typename IntTy>
4120 if (Width +
Offset < 32) {
4122 IntTy Result =
static_cast<IntTy
>(Shl) >> (32 - Width);
4123 if constexpr (std::is_signed_v<IntTy>) {
4136 if (M->isVolatile())
4288 EVT SrcVT = Src.getValueType();
4289 if (SrcVT.
bitsGE(ExtVT)) {
4300 unsigned IID =
N->getConstantOperandVal(0);
4302 case Intrinsic::amdgcn_mul_i24:
4303 case Intrinsic::amdgcn_mul_u24:
4304 case Intrinsic::amdgcn_mulhi_i24:
4305 case Intrinsic::amdgcn_mulhi_u24:
4307 case Intrinsic::amdgcn_fract:
4308 case Intrinsic::amdgcn_rsq:
4309 case Intrinsic::amdgcn_rcp_legacy:
4310 case Intrinsic::amdgcn_rsq_legacy:
4311 case Intrinsic::amdgcn_rsq_clamp:
4312 case Intrinsic::amdgcn_tanh:
4313 case Intrinsic::amdgcn_prng_b32: {
4316 return Src.isUndef() ? Src :
SDValue();
4318 case Intrinsic::amdgcn_frexp_exp: {
4324 if (PeekSign == Src)
4361 EVT VT =
N->getValueType(0);
4374 switch (LHS->getOpcode()) {
4382 if (VT == MVT::i32 && RHSVal == 16 &&
X.getValueType() == MVT::i16 &&
4396 unsigned LZ =
Known.countMinLeadingZeros();
4399 EVT XVT =
X.getValueType();
4431 ShiftAmt = DAG.
getNode(
ISD::AND, SL, TargetType, TruncShiftAmt, ShiftMask);
4442 EVT ConcatType = TargetType.getDoubleNumVectorElementsVT(*DAG.
getContext());
4443 unsigned NElts = TargetType.getVectorNumElements();
4448 for (
unsigned I = 0;
I != NElts; ++
I)
4449 HiAndLoOps[2 *
I + 1] = HiOps[
I];
4462 EVT VT =
N->getValueType(0);
4492 }
else if (
Known.getMinValue().getZExtValue() ==
4493 (ElementType.getSizeInBits() - 1)) {
4494 ShiftAmt = ShiftFullAmt;
4501 ShiftAmt = DAG.
getNode(
ISD::AND, SL, TargetType, TruncShiftAmt, ShiftMask);
4509 unsigned NElts = TargetType.getVectorNumElements();
4510 ConcatType = TargetType.getDoubleNumVectorElementsVT(*DAG.
getContext());
4516 for (
unsigned I = 0;
I != NElts; ++
I) {
4517 HiOps[
I] = HiAndLoOps[2 *
I + 1];
4534 CRHS->
getZExtValue() == (ElementType.getSizeInBits() - 1)) {
4535 NewShift = HiShift =
4546 unsigned NElts = TargetType.getVectorNumElements();
4553 for (
unsigned I = 0;
I != NElts; ++
I) {
4554 HiAndLoOps[2 *
I + 1] = HiOps[
I];
4555 HiAndLoOps[2 *
I] = LoOps[
I];
4568 EVT VT =
N->getValueType(0);
4581 unsigned MaskIdx, MaskLen;
4582 if (Mask->getAPIntValue().isShiftedMask(MaskIdx, MaskLen) &&
4583 MaskIdx == RHSVal) {
4622 ShiftAmt = DAG.
getNode(
ISD::AND, SL, TargetType, TruncShiftAmt, ShiftMask);
4631 unsigned NElts = TargetType.getVectorNumElements();
4632 ConcatType = TargetType.getDoubleNumVectorElementsVT(*DAG.
getContext());
4638 for (
unsigned I = 0;
I != NElts; ++
I)
4639 HiOps[
I] = HiAndLoOps[2 *
I + 1];
4653 unsigned NElts = TargetType.getVectorNumElements();
4658 for (
unsigned I = 0;
I != NElts; ++
I)
4659 HiAndLoOps[2 *
I] = LoOps[
I];
4671 EVT VT =
N->getValueType(0);
4700 unsigned BitIndex =
K->getZExtValue();
4701 unsigned PartIndex = BitIndex / SrcEltSize;
4703 if (PartIndex * SrcEltSize == BitIndex &&
4721 EVT SrcVT = Src.getValueType();
4733 const unsigned MaxCstSize =
4735 if (
Known.getMaxValue().ule(MaxCstSize)) {
4767 unsigned MulOpc =
Signed ? AMDGPUISD::MUL_I24 : AMDGPUISD::MUL_U24;
4768 return DAG.
getNode(MulOpc, SL, MVT::i32, N0, N1);
4771 unsigned MulLoOpc =
Signed ? AMDGPUISD::MUL_I24 : AMDGPUISD::MUL_U24;
4772 unsigned MulHiOpc =
Signed ? AMDGPUISD::MULHI_I24 : AMDGPUISD::MULHI_U24;
4792 EVT VT =
N->getValueType(0);
4798 if (!
N->isDivergent())
4820 if (V.hasOneUse() ||
all_of(V->users(), [](
const SDNode *U) ->
bool {
4821 return U->getOpcode() == ISD::MUL;
4830 if (
SDValue MulOper = IsFoldableAdd(N0)) {
4835 if (
SDValue MulOper = IsFoldableAdd(N1)) {
4856 if (Subtarget->hasMulU24() &&
isU24(N0, DAG) &&
isU24(N1, DAG)) {
4860 }
else if (Subtarget->hasMulI24() &&
isI24(N0, DAG) &&
isI24(N1, DAG)) {
4876 if (
N->getValueType(0) != MVT::i32)
4897 unsigned LoOpcode = 0;
4898 unsigned HiOpcode = 0;
4900 if (Subtarget->hasMulI24() &&
isI24(N0, DAG) &&
isI24(N1, DAG)) {
4903 LoOpcode = AMDGPUISD::MUL_I24;
4904 HiOpcode = AMDGPUISD::MULHI_I24;
4907 if (Subtarget->hasMulU24() &&
isU24(N0, DAG) &&
isU24(N1, DAG)) {
4910 LoOpcode = AMDGPUISD::MUL_U24;
4911 HiOpcode = AMDGPUISD::MULHI_U24;
4925 EVT VT =
N->getValueType(0);
4927 if (!Subtarget->hasMulI24() || VT.
isVector())
4936 if (Subtarget->hasSMulHi() && !
N->isDivergent())
4958 EVT VT =
N->getValueType(0);
4969 if (!
N->isDivergent() && Subtarget->hasSMulHi())
4992 unsigned Opc)
const {
4993 EVT VT =
Op.getValueType();
5030 isCttzOpc(RHS.getOpcode()) ? AMDGPUISD::FFBL_B32 : AMDGPUISD::FFBH_U32;
5031 return getFFBX_U32(DAG, CmpLHS, SL,
Opc);
5040 isCttzOpc(LHS.getOpcode()) ? AMDGPUISD::FFBL_B32 : AMDGPUISD::FFBH_U32;
5042 return getFFBX_U32(DAG, CmpLHS, SL,
Opc);
5060 return DAG.
getNode(
Op, SL, VT, NewSelect);
5078 EVT VT =
N.getValueType();
5105 bool ShouldFoldNeg =
true;
5110 ShouldFoldNeg =
false;
5112 ShouldFoldNeg =
false;
5115 if (ShouldFoldNeg) {
5139 Cond, NewLHS, NewRHS);
5141 return DAG.
getNode(LHS.getOpcode(), SL, VT, NewSelect);
5157 EVT VT =
N->getValueType(0);
5165 if (
Cond.hasOneUse()) {
5181 if (VT == MVT::f32 && Subtarget->hasFminFmaxLegacy()) {
5183 CC,
N->getFlags(), DCI);
5211 if (Subtarget->hasInv2PiInlineImm() &&
isInv2Pi(
C->getValueAPF()))
5247 case AMDGPUISD::FMAX_LEGACY:
5248 return AMDGPUISD::FMIN_LEGACY;
5249 case AMDGPUISD::FMIN_LEGACY:
5250 return AMDGPUISD::FMAX_LEGACY;
5281 EVT VT =
N->getValueType(0);
5288 bool MayIgnoreSignedZeroForAllUses =
5290 (N0.
hasOneUse() &&
N->getFlags().hasNoSignedZeros());
5295 if (!MayIgnoreSignedZeroForAllUses)
5320 case AMDGPUISD::FMUL_LEGACY: {
5343 if (!MayIgnoreSignedZeroForAllUses)
5378 case AMDGPUISD::FMAX_LEGACY:
5379 case AMDGPUISD::FMIN_LEGACY: {
5394 if ((
Opc == AMDGPUISD::FMIN_LEGACY ||
Opc == AMDGPUISD::FMAX_LEGACY) &&
5409 case AMDGPUISD::FMED3: {
5417 for (
unsigned I = 0;
I < 3; ++
I)
5421 if (Res.
getOpcode() != AMDGPUISD::FMED3)
5441 case AMDGPUISD::RCP:
5442 case AMDGPUISD::RCP_LEGACY:
5443 case AMDGPUISD::RCP_IFLAG:
5444 case AMDGPUISD::SIN_HW: {
5483 EVT SrcVT = Src.getValueType();
5519 Ops.back() = CastBack;
5569 EVT SrcVT = Src.getValueType();
5605 if (!Subtarget->isGCN())
5611 const auto *
TII = ST.getInstrInfo();
5613 if (!ST.hasVMovB64Inst() || (!SDConstant && !SDFPConstant))
5616 if (ST.has64BitLiterals())
5633 switch(
N->getOpcode()) {
5637 EVT DestVT =
N->getValueType(0);
5649 EVT SrcVT = Src.getValueType();
5679 uint64_t CVal =
C->getZExtValue();
5687 const APInt &Val =
C->getValueAPF().bitcastToAPInt();
5708 if (!(
N->getValueType(0).isVector() &&
5722 case AMDGPUISD::MUL_U24:
5723 case AMDGPUISD::MUL_I24: {
5728 case AMDGPUISD::MULHI_I24:
5729 case AMDGPUISD::MULHI_U24:
5744 case AMDGPUISD::BFE_I32:
5745 case AMDGPUISD::BFE_U32: {
5746 assert(
N->getValueType(0) == MVT::i32 &&
5747 "BFE_I32/BFE_U32 is a 32-bit operation");
5760 SDValue BitsFrom =
N->getOperand(0);
5763 bool Signed =
N->getOpcode() == AMDGPUISD::BFE_I32;
5765 if (OffsetVal == 0) {
5792 CVal->getSExtValue(),
5799 CVal->getZExtValue(),
5805 if ((OffsetVal + WidthVal) >= 32 &&
5806 !(OffsetVal == 16 && WidthVal == 16 && Subtarget->hasSDWA())) {
5809 BitsFrom, ShiftVal);
5815 OffsetVal + WidthVal);
5833 case AMDGPUISD::RCP:
5834 case AMDGPUISD::RCP_IFLAG:
5841 case AMDGPUISD::FMAD_FTZ: {
5845 EVT VT =
N->getValueType(0);
5852 if (N0CFP && N1CFP && N2CFP) {
5853 const auto FTZ = [](
const APFloat &V) {
5854 if (V.isDenormal()) {
5855 APFloat Zero(V.getSemantics(), 0);
5856 return V.isNegative() ? -Zero : Zero;
5878 unsigned Depth)
const {
5879 switch (
Op.getOpcode()) {
5881 switch (
Op.getConstantOperandVal(0)) {
5882 case Intrinsic::amdgcn_readfirstlane:
5883 case Intrinsic::amdgcn_readlane:
5884 case Intrinsic::amdgcn_wwm: {
5886 OriginalDemandedElts,
Known, TLO,
Depth + 1))
5890 case Intrinsic::amdgcn_set_inactive:
5891 case Intrinsic::amdgcn_set_inactive_chain_arg: {
5896 OriginalDemandedElts, KnownValue, TLO,
5900 OriginalDemandedElts, KnownInactive, TLO,
5926 bool RawReg)
const {
5986 DAG.
getCopyFromReg(Chain, SL, Info->getStackPtrOffsetReg(), MVT::i32);
5997 assert(Arg &&
"Attempting to load missing argument");
6006 unsigned Mask = Arg.
getMask();
6016 unsigned ExplicitArgOffset = Subtarget->getExplicitKernelArgOffset();
6017 const Align Alignment = Subtarget->getAlignmentForImplicitArgPtr();
6018 uint64_t ArgOffset =
6019 alignTo(ExplicitKernArgSize, Alignment) + ExplicitArgOffset;
6042 int &RefinementSteps,
6043 bool &UseOneConstNR,
6044 bool Reciprocal)
const {
6047 if (VT == MVT::f32) {
6048 RefinementSteps = 0;
6049 return DAG.
getNode(AMDGPUISD::RSQ,
SDLoc(Operand), VT, Operand);
6060 int &RefinementSteps)
const {
6063 if (VT == MVT::f32) {
6069 RefinementSteps = 0;
6070 return DAG.
getNode(AMDGPUISD::RCP,
SDLoc(Operand), VT, Operand);
6081 case Intrinsic::amdgcn_workitem_id_x:
6083 case Intrinsic::amdgcn_workitem_id_y:
6085 case Intrinsic::amdgcn_workitem_id_z:
6098 unsigned Opc =
Op.getOpcode();
6103 case AMDGPUISD::CARRY:
6104 case AMDGPUISD::BORROW: {
6109 case AMDGPUISD::BFE_I32:
6110 case AMDGPUISD::BFE_U32: {
6117 if (
Opc == AMDGPUISD::BFE_U32)
6122 case AMDGPUISD::FP_TO_FP16: {
6129 case AMDGPUISD::MUL_U24:
6130 case AMDGPUISD::MUL_I24: {
6133 unsigned BitWidth =
Op.getScalarValueSizeInBits();
6136 if (
Opc == AMDGPUISD::MUL_I24) {
6145 bool SelfMultiply =
Op.getOperand(0) ==
Op.getOperand(1);
6154 case AMDGPUISD::PERM: {
6163 for (
unsigned I = 0;
I < 32;
I += 8) {
6164 unsigned SelBits = Sel & 0xff;
6169 }
else if (SelBits < 7) {
6170 SelBits = (SelBits & 3) * 8;
6173 }
else if (SelBits == 0x0c) {
6174 Known.Zero |= 0xFFull <<
I;
6175 }
else if (SelBits > 0x0c) {
6176 Known.One |= 0xFFull <<
I;
6182 case AMDGPUISD::BUFFER_LOAD_UBYTE: {
6183 Known.Zero.setHighBits(24);
6186 case AMDGPUISD::BUFFER_LOAD_USHORT: {
6187 Known.Zero.setHighBits(16);
6190 case AMDGPUISD::LDS: {
6194 Known.Zero.setHighBits(16);
6198 case AMDGPUISD::SMIN3:
6199 case AMDGPUISD::SMAX3:
6200 case AMDGPUISD::SMED3:
6201 case AMDGPUISD::UMIN3:
6202 case AMDGPUISD::UMAX3:
6203 case AMDGPUISD::UMED3: {
6222 unsigned IID =
Op.getConstantOperandVal(0);
6224 case Intrinsic::amdgcn_workitem_id_x:
6225 case Intrinsic::amdgcn_workitem_id_y:
6226 case Intrinsic::amdgcn_workitem_id_z: {
6227 unsigned MaxValue = Subtarget->getMaxWorkitemID(
6232 case Intrinsic::amdgcn_readfirstlane:
6233 case Intrinsic::amdgcn_readlane:
6246 unsigned Depth)
const {
6247 switch (
Op.getOpcode()) {
6248 case AMDGPUISD::BFE_I32: {
6253 unsigned SignBits = 32 - (Width->
getZExtValue() & 0x1f) + 1;
6259 return std::max(SignBits, Op0SignBits);
6262 case AMDGPUISD::BFE_U32: {
6264 return Width ? 32 - (Width->
getZExtValue() & 0x1f) : 1;
6267 case AMDGPUISD::CARRY:
6268 case AMDGPUISD::BORROW:
6270 case AMDGPUISD::BUFFER_LOAD_BYTE:
6272 case AMDGPUISD::BUFFER_LOAD_SHORT:
6274 case AMDGPUISD::BUFFER_LOAD_UBYTE:
6276 case AMDGPUISD::BUFFER_LOAD_USHORT:
6278 case AMDGPUISD::FP_TO_FP16:
6280 case AMDGPUISD::SMIN3:
6281 case AMDGPUISD::SMAX3:
6282 case AMDGPUISD::SMED3:
6283 case AMDGPUISD::UMIN3:
6284 case AMDGPUISD::UMAX3:
6285 case AMDGPUISD::UMED3: {
6298 return std::min({Tmp0, Tmp1, Tmp2});
6313 switch (
MI->getOpcode()) {
6314 case AMDGPU::G_AMDGPU_BUFFER_LOAD_SBYTE:
6316 case AMDGPU::G_AMDGPU_BUFFER_LOAD_SSHORT:
6318 case AMDGPU::G_AMDGPU_BUFFER_LOAD_UBYTE:
6320 case AMDGPU::G_AMDGPU_BUFFER_LOAD_USHORT:
6322 case AMDGPU::G_AMDGPU_SMED3:
6323 case AMDGPU::G_AMDGPU_UMED3: {
6324 auto [Dst, Src0, Src1, Src2] =
MI->getFirst4Regs();
6325 unsigned Tmp2 =
Analysis.computeNumSignBits(Src2, DemandedElts,
Depth + 1);
6328 unsigned Tmp1 =
Analysis.computeNumSignBits(Src1, DemandedElts,
Depth + 1);
6331 unsigned Tmp0 =
Analysis.computeNumSignBits(Src0, DemandedElts,
Depth + 1);
6334 return std::min({Tmp0, Tmp1, Tmp2});
6344 unsigned Opcode =
Op.getOpcode();
6346 case AMDGPUISD::BFE_I32:
6347 case AMDGPUISD::BFE_U32:
6351 Op, DemandedElts, DAG, Kind, ConsiderFlags,
Depth);
6356 unsigned Depth)
const {
6357 unsigned Opcode =
Op.getOpcode();
6359 case AMDGPUISD::FMIN_LEGACY:
6360 case AMDGPUISD::FMAX_LEGACY:
6363 case AMDGPUISD::FMUL_LEGACY:
6364 case AMDGPUISD::CVT_PKRTZ_F16_F32: {
6370 case AMDGPUISD::FMED3:
6371 case AMDGPUISD::FMIN3:
6372 case AMDGPUISD::FMAX3:
6373 case AMDGPUISD::FMINIMUM3:
6374 case AMDGPUISD::FMAXIMUM3:
6375 case AMDGPUISD::FMAD_FTZ: {
6382 case AMDGPUISD::CVT_F32_UBYTE0:
6383 case AMDGPUISD::CVT_F32_UBYTE1:
6384 case AMDGPUISD::CVT_F32_UBYTE2:
6385 case AMDGPUISD::CVT_F32_UBYTE3:
6388 case AMDGPUISD::RCP:
6389 case AMDGPUISD::RSQ:
6390 case AMDGPUISD::RCP_LEGACY:
6391 case AMDGPUISD::RSQ_CLAMP: {
6399 case AMDGPUISD::FRACT: {
6404 case AMDGPUISD::DIV_SCALE:
6405 case AMDGPUISD::DIV_FMAS:
6406 case AMDGPUISD::DIV_FIXUP:
6409 case AMDGPUISD::SIN_HW:
6410 case AMDGPUISD::COS_HW: {
6415 unsigned IntrinsicID =
Op.getConstantOperandVal(0);
6417 switch (IntrinsicID) {
6418 case Intrinsic::amdgcn_cubeid:
6419 case Intrinsic::amdgcn_cvt_off_f32_i4:
6422 case Intrinsic::amdgcn_frexp_mant: {
6427 case Intrinsic::amdgcn_cvt_pkrtz: {
6433 case Intrinsic::amdgcn_rcp:
6434 case Intrinsic::amdgcn_rsq:
6435 case Intrinsic::amdgcn_rcp_legacy:
6436 case Intrinsic::amdgcn_rsq_legacy:
6437 case Intrinsic::amdgcn_rsq_clamp:
6438 case Intrinsic::amdgcn_tanh: {
6445 case Intrinsic::amdgcn_trig_preop:
6446 case Intrinsic::amdgcn_fdot2:
6449 case Intrinsic::amdgcn_fma_legacy:
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
AMDGPU address space definition.
static LLVM_READONLY bool hasSourceMods(const MachineInstr &MI)
static bool isInv2Pi(const APFloat &APF)
static LLVM_READONLY bool opMustUseVOP3Encoding(const MachineInstr &MI, const MachineRegisterInfo &MRI)
returns true if the operation will definitely need to use a 64-bit encoding, and thus will use a VOP3...
static unsigned inverseMinMax(unsigned Opc)
static SDValue extractF64Exponent(SDValue Hi, const SDLoc &SL, SelectionDAG &DAG)
static unsigned workitemIntrinsicDim(unsigned ID)
static int getOrCreateFixedStackObject(MachineFrameInfo &MFI, unsigned Size, int64_t Offset)
static SDValue constantFoldBFE(SelectionDAG &DAG, IntTy Src0, uint32_t Offset, uint32_t Width, const SDLoc &DL)
static SDValue getMad(SelectionDAG &DAG, const SDLoc &SL, EVT VT, SDValue X, SDValue Y, SDValue C, SDNodeFlags Flags=SDNodeFlags())
static SDValue getAddOneOp(const SDNode *V)
If V is an add of a constant 1, returns the other operand.
static bool canIgnoreLegacyMinMaxTies(const SelectionDAG &DAG, SDNodeFlags Flags, SDValue LHS, SDValue RHS)
static LLVM_READONLY bool selectSupportsSourceMods(const SDNode *N)
Return true if v_cndmask_b32 will support fabs/fneg source modifiers for the type for ISD::SELECT.
static cl::opt< bool > AMDGPUBypassSlowDiv("amdgpu-bypass-slow-div", cl::desc("Skip 64-bit divide for dynamic 32-bit values"), cl::init(true))
static SDValue getMul24(SelectionDAG &DAG, const SDLoc &SL, SDValue N0, SDValue N1, unsigned Size, bool Signed)
static bool fnegFoldsIntoOp(const SDNode *N)
static bool isI24(SDValue Op, SelectionDAG &DAG)
static bool isCttzOpc(unsigned Opc)
static bool isU24(SDValue Op, SelectionDAG &DAG)
static bool valueIsKnownNeverF32Denorm(SDValue Src)
Return true if it's known that Src can never be an f32 denormal value.
static SDValue distributeOpThroughSelect(TargetLowering::DAGCombinerInfo &DCI, unsigned Op, const SDLoc &SL, SDValue Cond, SDValue N1, SDValue N2)
static SDValue peekFNeg(SDValue Val)
static SDValue simplifyMul24(SDNode *Node24, TargetLowering::DAGCombinerInfo &DCI)
static bool isCtlzOpc(unsigned Opc)
static LLVM_READNONE bool fnegFoldsIntoOpcode(unsigned Opc)
static bool hasVolatileUser(SDNode *Val)
Interface definition of the TargetLowering class that is common to all AMD GPUs.
Contains the definition of a TargetInstrInfo class that is common to all AMD GPUs.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Function Alias Analysis Results
block Block Frequency Analysis
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
Provides analysis for querying information about KnownBits during GISel passes.
const HexagonInstrInfo * TII
static MaybeAlign getAlign(Value *Ptr)
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
const SmallVectorImpl< MachineOperand > & Cond
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
static CCAssignFn * CCAssignFnForCall(CallingConv::ID CC, bool IsVarArg)
static CCAssignFn * CCAssignFnForReturn(CallingConv::ID CC, bool IsVarArg)
unsigned allocateBarrierGlobal(const DataLayout &DL, const GlobalVariable &GV)
uint64_t getExplicitKernArgSize() const
bool isModuleEntryFunction() const
static std::optional< uint32_t > get32BitAbsoluteAddress(const GlobalValue &GV, unsigned AS)
unsigned allocateLDSGlobal(const DataLayout &DL, const GlobalVariable &GV)
static unsigned numBitsSigned(SDValue Op, SelectionDAG &DAG)
unsigned ComputeNumSignBitsForTargetNode(SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG, unsigned Depth=0) const override
This method can be implemented by targets that want to expose additional information about sign bits ...
SDValue performMulhuCombine(SDNode *N, DAGCombinerInfo &DCI) const
EVT getTypeForExtReturn(LLVMContext &Context, EVT VT, ISD::NodeType ExtendKind) const override
Return the type that should be used to zero or sign extend a zeroext/signext integer return value.
SDValue SplitVectorLoad(SDValue Op, SelectionDAG &DAG) const
Split a vector load into 2 loads of half the vector.
SDValue LowerCONCAT_VECTORS(SDValue Op, SelectionDAG &DAG) const
SDValue performLoadCombine(SDNode *N, DAGCombinerInfo &DCI) const
void analyzeFormalArgumentsCompute(CCState &State, const SmallVectorImpl< ISD::InputArg > &Ins) const
The SelectionDAGBuilder will automatically promote function arguments with illegal types.
SDValue LowerF64ToF16Safe(SDValue Src, const SDLoc &DL, SelectionDAG &DAG) const
SDValue LowerFROUND(SDValue Op, SelectionDAG &DAG) const
SDValue storeStackInputValue(SelectionDAG &DAG, const SDLoc &SL, SDValue Chain, SDValue ArgVal, int64_t Offset) const
bool storeOfVectorConstantIsCheap(bool IsZero, EVT MemVT, unsigned NumElem, unsigned AS) const override
Return true if it is expected to be cheaper to do a store of vector constant with the given size and ...
SDValue LowerEXTRACT_SUBVECTOR(SDValue Op, SelectionDAG &DAG) const
void computeKnownBitsForTargetNode(const SDValue Op, KnownBits &Known, const APInt &DemandedElts, const SelectionDAG &DAG, unsigned Depth=0) const override
Determine which of the bits specified in Mask are known to be either zero or one and return them in t...
bool shouldCombineMemoryType(EVT VT) const
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...
SDValue lowerUnhandledCall(CallLoweringInfo &CLI, SmallVectorImpl< SDValue > &InVals, StringRef Reason) const
virtual SDValue LowerGlobalAddress(AMDGPUMachineFunctionInfo *MFI, SDValue Op, SelectionDAG &DAG) const
SDValue performAssertSZExtCombine(SDNode *N, DAGCombinerInfo &DCI) const
bool isTruncateFree(EVT Src, EVT Dest) const override
bool aggressivelyPreferBuildVectorSources(EVT VecVT) const override
SDValue LowerFCEIL(SDValue Op, SelectionDAG &DAG) const
TargetLowering::NegatibleCost getConstantNegateCost(const ConstantFPSDNode *C) const
SDValue LowerFLOGUnsafe(SDValue Op, const SDLoc &SL, SelectionDAG &DAG, bool IsLog10, SDNodeFlags Flags) const
SDValue combineFMinMaxLegacy(const SDLoc &DL, EVT VT, SDValue LHS, SDValue RHS, SDValue True, SDValue False, SDValue CC, SDNodeFlags Flags, DAGCombinerInfo &DCI) const
Flags must be the select flags, not the compare (SELECT_CC flags come from the fcmp and say nothing a...
SDValue performMulhsCombine(SDNode *N, DAGCombinerInfo &DCI) const
SDValue lowerFEXPUnsafeImpl(SDValue Op, const SDLoc &SL, SelectionDAG &DAG, SDNodeFlags Flags, bool IsExp10) const
bool isSDNodeAlwaysUniform(const SDNode *N) const override
bool isDesirableToCommuteWithShift(const SDNode *N, CombineLevel Level) const override
Return true if it is profitable to move this shift by a constant amount through its operand,...
SDValue performShlCombine(SDNode *N, DAGCombinerInfo &DCI) const
bool isCheapToSpeculateCtlz(Type *Ty) const override
Return true if it is cheap to speculate a call to intrinsic ctlz.
SDValue LowerSDIVREM(SDValue Op, SelectionDAG &DAG) const
bool isFNegFree(EVT VT) const override
Return true if an fneg operation is free to the point where it is never worthwhile to replace it with...
SDValue LowerFLOG10(SDValue Op, SelectionDAG &DAG) const
SDValue LowerINT_TO_FP64(SDValue Op, SelectionDAG &DAG, bool Signed) const
unsigned computeNumSignBitsForTargetInstr(GISelValueTracking &Analysis, Register R, const APInt &DemandedElts, const MachineRegisterInfo &MRI, unsigned Depth=0) const override
This method can be implemented by targets that want to expose additional information about sign bits ...
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...
SDValue LowerFP_TO_FP16(SDValue Op, SelectionDAG &DAG) const
SDValue addTokenForArgument(SDValue Chain, SelectionDAG &DAG, MachineFrameInfo &MFI, int ClobberedFI) const
bool isConstantCheaperToNegate(SDValue N) const
bool isReassocProfitable(MachineRegisterInfo &MRI, Register N0, Register N1) const override
bool isKnownNeverNaNForTargetNode(SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG, bool SNaN=false, unsigned Depth=0) const override
If SNaN is false,.
static bool needsDenormHandlingF32(const SelectionDAG &DAG, SDValue Src, SDNodeFlags Flags)
SDValue lowerFPOW(SDValue Op, SelectionDAG &DAG) const
uint32_t getImplicitParameterOffset(const MachineFunction &MF, const ImplicitParameter Param) const
Helper function that returns the byte offset of the given type of implicit parameter.
SDValue lowerFEXPF64(SDValue Op, SelectionDAG &DAG) const
SDValue LowerFFLOOR(SDValue Op, SelectionDAG &DAG) const
SDValue performSelectCombine(SDNode *N, DAGCombinerInfo &DCI) const
SDValue performFNegCombine(SDNode *N, DAGCombinerInfo &DCI) const
SDValue LowerFP_TO_INT(SDValue Op, SelectionDAG &DAG) const
bool isConstantCostlierToNegate(SDValue N) const
SDValue loadInputValue(SelectionDAG &DAG, const TargetRegisterClass *RC, EVT VT, const SDLoc &SL, const ArgDescriptor &Arg) const
SDValue lowerFEXP10Unsafe(SDValue Op, const SDLoc &SL, SelectionDAG &DAG, SDNodeFlags Flags) const
Emit approx-funcs appropriate lowering for exp10.
bool shouldReduceLoadWidth(SDNode *Load, ISD::LoadExtType ExtType, EVT ExtVT, std::optional< unsigned > ByteOffset) const override
Return true if it is profitable to reduce a load to a smaller type.
SDValue LowerUINT_TO_FP(SDValue Op, SelectionDAG &DAG) const
bool canCreateUndefOrPoisonForTargetNode(SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG, UndefPoisonKind Kind, bool ConsiderFlags, unsigned Depth) const override
Return true if Op can create undef or poison from non-undef & non-poison operands.
bool isCheapToSpeculateCttz(Type *Ty) const override
Return true if it is cheap to speculate a call to intrinsic cttz.
SDValue performCtlz_CttzCombine(const SDLoc &SL, SDValue Cond, SDValue LHS, SDValue RHS, DAGCombinerInfo &DCI) const
SDValue performSraCombine(SDNode *N, DAGCombinerInfo &DCI) const
bool isSelectSupported(SelectSupportKind) const override
bool isZExtFree(Type *Src, Type *Dest) const override
Return true if any actual instruction that defines a value of type FromTy implicitly zero-extends the...
SDValue lowerFEXP2(SDValue Op, SelectionDAG &DAG) const
SDValue LowerCall(CallLoweringInfo &CLI, SmallVectorImpl< SDValue > &InVals) const override
This hook must be implemented to lower calls into the specified DAG.
SDValue performSrlCombine(SDNode *N, DAGCombinerInfo &DCI) const
SDValue lowerFEXP(SDValue Op, SelectionDAG &DAG) const
SDValue getIsLtSmallestNormal(SelectionDAG &DAG, SDValue Op, SDNodeFlags Flags) const
SDValue getIsFinite(SelectionDAG &DAG, SDValue Op, SDNodeFlags Flags) const
bool isLoadBitCastBeneficial(EVT, EVT, const SelectionDAG &DAG, const MachineMemOperand &MMO) const final
Return true if the following transform is beneficial: fold (conv (load x)) -> (load (conv*)x) On arch...
std::pair< SDValue, SDValue > splitVector(const SDValue &N, const SDLoc &DL, const EVT &LoVT, const EVT &HighVT, SelectionDAG &DAG) const
Split a vector value into two parts of types LoVT and HiVT.
AMDGPUTargetLowering(const TargetMachine &TM, const TargetSubtargetInfo &STI, const AMDGPUSubtarget &AMDGPUSTI)
SDValue LowerFLOGCommon(SDValue Op, SelectionDAG &DAG) const
SDValue foldFreeOpFromSelect(TargetLowering::DAGCombinerInfo &DCI, SDValue N) const
SDValue LowerINT_TO_FP32(SDValue Op, SelectionDAG &DAG, bool Signed) const
bool isFAbsFree(EVT VT) const override
Return true if an fabs operation is free to the point where it is never worthwhile to replace it with...
bool isInt64ImmLegal(SDNode *Val, SelectionDAG &DAG) const
Check whether value Val can be supported by v_mov_b64, for the current target.
SDValue loadStackInputValue(SelectionDAG &DAG, EVT VT, const SDLoc &SL, int64_t Offset) const
Similar to CreateLiveInRegister, except value maybe loaded from a stack slot rather than passed in a ...
SDValue LowerFLOG2(SDValue Op, SelectionDAG &DAG) const
static EVT getEquivalentMemType(LLVMContext &Context, EVT VT)
SDValue LowerCTLS(SDValue Op, SelectionDAG &DAG) const
Split a vector store into multiple scalar stores.
SDValue getSqrtEstimate(SDValue Operand, SelectionDAG &DAG, int Enabled, int &RefinementSteps, bool &UseOneConstNR, bool Reciprocal) const override
Hooks for building estimates in place of slower divisions and square roots.
SDValue performTruncateCombine(SDNode *N, DAGCombinerInfo &DCI) const
SDValue LowerSINT_TO_FP(SDValue Op, SelectionDAG &DAG) const
static SDValue stripBitcast(SDValue Val)
SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const
SDValue CreateLiveInRegister(SelectionDAG &DAG, const TargetRegisterClass *RC, Register Reg, EVT VT, const SDLoc &SL, bool RawReg=false) const
Helper function that adds Reg to the LiveIn list of the DAG's MachineFunction.
SDValue SplitVectorStore(SDValue Op, SelectionDAG &DAG) const
Split a vector store into 2 stores of half the vector.
SDValue LowerCTLZ_CTTZ(SDValue Op, SelectionDAG &DAG) const
SDValue getNegatedExpression(SDValue Op, SelectionDAG &DAG, bool LegalOperations, bool ForCodeSize, NegatibleCost &Cost, unsigned Depth) const override
Return the newly negated expression if the cost is not expensive and set the cost in Cost to indicate...
std::pair< SDValue, SDValue > split64BitValue(SDValue Op, SelectionDAG &DAG) const
Return 64-bit value Op as two 32-bit integers.
SDValue performMulCombine(SDNode *N, DAGCombinerInfo &DCI) const
SDValue combineFMinMaxLegacyImpl(const SDLoc &DL, EVT VT, SDValue LHS, SDValue RHS, SDValue True, SDValue False, SDValue CC, SDNodeFlags Flags, DAGCombinerInfo &DCI) const
SDValue getRecipEstimate(SDValue Operand, SelectionDAG &DAG, int Enabled, int &RefinementSteps) const override
Return a reciprocal estimate value for the input operand.
SDValue LowerFNEARBYINT(SDValue Op, SelectionDAG &DAG) const
SDValue LowerSIGN_EXTEND_INREG(SDValue Op, SelectionDAG &DAG) const
static CCAssignFn * CCAssignFnForReturn(CallingConv::ID CC, bool IsVarArg)
std::pair< SDValue, SDValue > getScaledLogInput(SelectionDAG &DAG, const SDLoc SL, SDValue Op, SDNodeFlags Flags) const
If denormal handling is required return the scaled input to FLOG2, and the check for denormal range.
static CCAssignFn * CCAssignFnForCall(CallingConv::ID CC, bool IsVarArg)
Selects the correct CCAssignFn for a given CallingConvention value.
bool SimplifyDemandedBitsForTargetNode(SDValue Op, const APInt &OriginalDemandedBits, const APInt &OriginalDemandedElts, KnownBits &Known, TargetLoweringOpt &TLO, unsigned Depth) const override
Attempt to simplify any target nodes based on the demanded bits/elts, returning true on success.
static bool allUsesHaveSourceMods(const SDNode *N, unsigned CostThreshold=4)
SDValue LowerFROUNDEVEN(SDValue Op, SelectionDAG &DAG) const
bool isFPImmLegal(const APFloat &Imm, EVT VT, bool ForCodeSize) const override
Returns true if the target can instruction select the specified FP immediate natively.
static unsigned numBitsUnsigned(SDValue Op, SelectionDAG &DAG)
SDValue lowerFEXPUnsafe(SDValue Op, const SDLoc &SL, SelectionDAG &DAG, SDNodeFlags Flags) const
SDValue LowerFTRUNC(SDValue Op, SelectionDAG &DAG) const
SDValue LowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG) const
static bool allowApproxFunc(const SelectionDAG &DAG, SDNodeFlags Flags)
bool ShouldShrinkFPConstant(EVT VT) const override
If true, then instruction selection should seek to shrink the FP constant of the specified type to a ...
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,...
SDValue performStoreCombine(SDNode *N, DAGCombinerInfo &DCI) 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...
SDValue performRcpCombine(SDNode *N, DAGCombinerInfo &DCI) const
SDValue getLoHalf64(SDValue Op, SelectionDAG &DAG) const
SDValue lowerCTLZResults(SDValue Op, SelectionDAG &DAG) const
SDValue LowerFP_TO_INT_SAT(SDValue Op, SelectionDAG &DAG) const
SDValue performFAbsCombine(SDNode *N, DAGCombinerInfo &DCI) const
SDValue LowerFP_TO_INT64(SDValue Op, SelectionDAG &DAG, bool Signed) const
static bool shouldFoldFNegIntoSrc(SDNode *FNeg, SDValue FNegSrc)
bool isNarrowingProfitable(SDNode *N, EVT SrcVT, EVT DestVT) const override
Return true if it's profitable to narrow operations of type SrcVT to DestVT.
SDValue LowerFRINT(SDValue Op, SelectionDAG &DAG) const
SDValue performIntrinsicWOChainCombine(SDNode *N, DAGCombinerInfo &DCI) const
SDValue LowerUDIVREM(SDValue Op, SelectionDAG &DAG) const
SDValue performMulLoHiCombine(SDNode *N, DAGCombinerInfo &DCI) const
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 lowerINT_TO_FPImpl(SDValue Op, SelectionDAG &DAG, bool Signed) const
void LowerUDIVREM64(SDValue Op, SelectionDAG &DAG, SmallVectorImpl< SDValue > &Results) const
SDValue WidenOrSplitVectorLoad(SDValue Op, SelectionDAG &DAG) const
Widen a suitably aligned v3 load.
SDValue LowerDIVREMToFloat(SDValue Op, SelectionDAG &DAG, bool sign) const
std::pair< EVT, EVT > getSplitDestVTs(const EVT &VT, SelectionDAG &DAG) const
Split a vector type into two parts.
SDValue getHiHalf64(SDValue Op, SelectionDAG &DAG) const
SDValue LowerINT_TO_FP16(SDValue Op, SelectionDAG &DAG, EVT FP16Ty) const
unsigned getVectorIdxWidth(const DataLayout &) const override
Returns the type to be used for the index operand vector operations.
static const fltSemantics & IEEEsingle()
static const fltSemantics & IEEEdouble()
static constexpr roundingMode rmNearestTiesToEven
static const fltSemantics & IEEEhalf()
static APFloat getQNaN(const fltSemantics &Sem, bool Negative=false, const APInt *payload=nullptr)
Factory for QNaN values.
bool bitwiseIsEqual(const APFloat &RHS) const
static APFloat getSmallestNormalized(const fltSemantics &Sem, bool Negative=false)
Returns the smallest (by magnitude) normalized finite number in the given semantics.
APInt bitcastToAPInt() const
static APFloat getInf(const fltSemantics &Sem, bool Negative=false)
Factory for Positive and Negative Infinity.
Class for arbitrary precision integers.
uint64_t getZExtValue() const
Get zero extended value.
static APInt getMaxValue(unsigned numBits)
Gets maximum unsigned value of APInt for specific bit width.
static APInt getBitsSet(unsigned numBits, unsigned loBit, unsigned hiBit)
Get a value with a block of bits set.
static APInt getSignedMaxValue(unsigned numBits)
Gets maximum signed value of APInt for a specific bit width.
static APInt getSignedMinValue(unsigned numBits)
Gets minimum signed value of APInt for a specific bit width.
static APInt getLowBitsSet(unsigned numBits, unsigned loBitsSet)
Constructs an APInt value that has the bottom loBitsSet bits set.
static APInt getHighBitsSet(unsigned numBits, unsigned hiBitsSet)
Constructs an APInt value that has the top hiBitsSet bits set.
This class represents an incoming formal argument to a Function.
int64_t getOffset() const
unsigned getTargetFlags() const
const BlockAddress * getBlockAddress() const
CCState - This class holds information needed while lowering arguments and return values.
static CCValAssign getCustomMem(unsigned ValNo, MVT ValVT, int64_t Offset, MVT LocVT, LocInfo HTP)
const APFloat & getValueAPF() const
bool isNegative() const
Return true if the value is negative.
uint64_t getZExtValue() const
const APInt & getAPIntValue() const
A parsed version of the target data layout string in and methods for querying it.
Diagnostic information for unsupported feature in backend.
const DataLayout & getDataLayout() const
Get the data layout of the module this function belongs to.
iterator_range< arg_iterator > args()
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
This is an important class for using LLVM in a threaded context.
LLVM_ABI void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
This class is used to represent ISD::LOAD nodes.
const SDValue & getBasePtr() const
static auto integer_fixedlen_vector_valuetypes()
uint64_t getScalarSizeInBits() const
unsigned getVectorNumElements() const
bool isVector() const
Return true if this is a vector value type.
bool isInteger() const
Return true if this is an integer or a vector integer type.
static auto integer_valuetypes()
bool isFloatingPoint() const
Return true if this is a FP or a vector FP type.
MVT getScalarType() const
If this is a vector, return the element type, otherwise return this.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
LLVM_ABI int CreateFixedObject(uint64_t Size, int64_t SPOffset, bool IsImmutable, bool isAliased=false)
Create a new object at a fixed location on the stack.
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
int64_t getObjectOffset(int ObjectIdx) const
Return the assigned stack offset of the specified object from the incoming stack pointer.
int getObjectIndexBegin() const
Return the minimum frame object index.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
DenormalMode getDenormalMode(const fltSemantics &FPType) const
Returns the denormal handling type for the default rounding mode of the function.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Function & getFunction()
Return the LLVM function that this machine code represents.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
Representation of each machine instruction.
A description of a memory reference used in the backend.
@ MODereferenceable
The memory access is dereferenceable (i.e., doesn't trap).
@ MOInvariant
The memory access always returns the same value (or traps).
Flags getFlags() const
Return the raw flags of the source value,.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
LLVM_ABI bool hasOneNonDBGUse(Register RegNo) const
hasOneNonDBGUse - Return true if there is exactly one non-Debug use of the specified register.
LLVM_ABI LLVM_READONLY MachineInstr * getVRegDef(Register Reg) const
getVRegDef - Return the machine instr that defines the specified virtual register or null if none is ...
LLVM_ABI Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
LLVM_ABI bool isLiveIn(Register Reg) const
LLVM_ABI Register getLiveInVirtReg(MCRegister PReg) const
getLiveInVirtReg - If PReg is a live-in physical register, return the corresponding live-in virtual r...
void addLiveIn(MCRegister Reg, Register vreg=Register())
addLiveIn - Add the specified register as a live-in.
This is an abstract virtual class for memory operations.
unsigned getAddressSpace() const
Return the address space for the associated pointer.
bool isSimple() const
Returns true if the memory operation is neither atomic or volatile.
MachineMemOperand * getMemOperand() const
Return the unique MachineMemOperand object describing the memory reference performed by operation.
const SDValue & getChain() const
EVT getMemoryVT() const
Return the type of the in-memory value.
Wrapper class representing virtual and physical registers.
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
const DebugLoc & getDebugLoc() const
Represents one node in the SelectionDAG.
ArrayRef< SDUse > ops() const
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
bool hasOneUse() const
Return true if there is exactly one use of this node.
SDNodeFlags getFlags() const
SDVTList getVTList() const
const SDValue & getOperand(unsigned Num) const
uint64_t getConstantOperandVal(unsigned Num) const
Helper method returns the integer value of a ConstantSDNode operand.
iterator_range< user_iterator > users()
Represents a use of a SDNode.
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
SDNode * getNode() const
get the SDNode which holds the desired result
bool hasOneUse() const
Return true if there is exactly one node using value ResNo of Node, in exactly one operand.
SDValue getValue(unsigned R) const
EVT getValueType() const
Return the ValueType of the referenced return value.
TypeSize getValueSizeInBits() const
Returns the size of the value in bits.
const SDValue & getOperand(unsigned i) const
unsigned getOpcode() const
unsigned getNumOperands() const
This class keeps track of the SPI_SP_INPUT_ADDR config register, which tells the hardware which inter...
SIModeRegisterDefaults getMode() const
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
LLVM_ABI bool isKnownNeverLogicalZero(SDValue Op, const APInt &DemandedElts, unsigned Depth=0) const
Test whether the given floating point SDValue (or all elements of it, if it is a vector) is known to ...
SDValue getExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT, unsigned Opcode)
Convert Op, which must be of integer type, to the integer type VT, by either any/sign/zero-extending ...
LLVM_ABI unsigned ComputeMaxSignificantBits(SDValue Op, unsigned Depth=0) const
Get the upper bound on bit size for this Value Op as a signed integer.
const SDValue & getRoot() const
Return the root tag of the SelectionDAG.
const TargetSubtargetInfo & getSubtarget() const
LLVM_ABI SDValue getMergeValues(ArrayRef< SDValue > Ops, const SDLoc &dl)
Create a MERGE_VALUES node from the given operands.
LLVM_ABI SDVTList getVTList(EVT VT)
Return an SDVTList that represents the list of values specified.
LLVM_ABI SDValue getShiftAmountConstant(uint64_t Val, EVT VT, const SDLoc &DL)
LLVM_ABI SDValue getAllOnesConstant(const SDLoc &DL, EVT VT, bool IsTarget=false, bool IsOpaque=false)
LLVM_ABI void ExtractVectorElements(SDValue Op, SmallVectorImpl< SDValue > &Args, unsigned Start=0, unsigned Count=0, EVT EltVT=EVT())
Append the extracted elements from Start to Count out of the vector Op in Args.
LLVM_ABI SDValue getFreeze(SDValue V)
Return a freeze using the SDLoc of the value operand.
LLVM_ABI SDValue getConstantFP(double Val, const SDLoc &DL, EVT VT, bool isTarget=false)
Create a ConstantFPSDNode wrapping a constant value.
LLVM_ABI SDValue getRegister(Register Reg, EVT VT)
SDValue getSetCC(const SDLoc &DL, EVT VT, SDValue LHS, SDValue RHS, ISD::CondCode Cond, SDValue Chain=SDValue(), bool IsSignaling=false, SDNodeFlags Flags={})
Helper function to make it easier to build SetCC's if you just have an ISD::CondCode instead of an SD...
LLVM_ABI SDValue getNOT(const SDLoc &DL, SDValue Val, EVT VT)
Create a bitwise NOT operation as (XOR Val, -1).
const TargetLowering & getTargetLoweringInfo() const
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).
SDValue getBuildVector(EVT VT, const SDLoc &DL, ArrayRef< SDValue > Ops)
Return an ISD::BUILD_VECTOR node.
LLVM_ABI SDValue getTruncStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, SDValue Offset, MachinePointerInfo PtrInfo, EVT SVT, Align Alignment, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const MMOMetadata &Metadata=MMOMetadata())
LLVM_ABI SDValue getBitcast(EVT VT, SDValue V)
Return a bitcast using the SDLoc of the value operand, and casting to the provided type.
SDValue getCopyFromReg(SDValue Chain, const SDLoc &dl, Register Reg, EVT VT)
SDValue getSelect(const SDLoc &DL, EVT VT, SDValue Cond, SDValue LHS, SDValue RHS, SDNodeFlags Flags=SDNodeFlags())
Helper function to make it easier to build Select's if you just have operands and don't want to check...
LLVM_ABI 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.
const DataLayout & getDataLayout() const
LLVM_ABI SDValue getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, Align Alignment, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const MMOMetadata &Metadata=MMOMetadata())
Helper function to build ISD::STORE nodes.
LLVM_ABI SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
Create a ConstantSDNode wrapping a constant value.
LLVM_ABI void ReplaceAllUsesWith(SDValue From, SDValue To)
Modify anything using 'From' to use 'To' instead.
LLVM_ABI SDValue getExtLoad(ISD::LoadExtType ExtType, const SDLoc &dl, EVT VT, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, EVT MemVT, MaybeAlign Alignment=MaybeAlign(), MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const MMOMetadata &Metadata=MMOMetadata())
LLVM_ABI SDValue getSignedConstant(int64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
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 ...
bool isConstantValueOfAnyType(SDValue N) const
SDValue getSelectCC(const SDLoc &DL, SDValue LHS, SDValue RHS, SDValue True, SDValue False, ISD::CondCode Cond, SDNodeFlags Flags=SDNodeFlags())
Helper function to make it easier to build SelectCC's if you just have an ISD::CondCode instead of an...
LLVM_ABI 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...
LLVM_ABI SDValue getLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, MaybeAlign Alignment=MaybeAlign(), MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const MMOMetadata &Metadata=MMOMetadata())
Loads are not normal binary operators: their result type is not determined by their operands,...
LLVM_ABI KnownFPClass computeKnownFPClass(SDValue Op, FPClassTest InterestedClasses, unsigned Depth=0) const
Determine floating-point class information about Op.
LLVM_ABI bool isGuaranteedNotToBeUndefOrPoison(SDValue Op, UndefPoisonKind Kind=UndefPoisonKind::UndefOrPoison, unsigned Depth=0) const
Return true if this function can prove that Op is never poison and, Kind can be used to track poison ...
LLVM_ABI SDValue getIntPtrConstant(uint64_t Val, const SDLoc &DL, bool isTarget=false)
LLVM_ABI SDValue getValueType(EVT)
LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
LLVM_ABI bool isKnownNeverNaN(SDValue Op, const APInt &DemandedElts, bool SNaN=false, unsigned Depth=0) const
Test whether the given SDValue (or all elements of it, if it is a vector) is known to never be NaN in...
SDValue getTargetConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isOpaque=false)
LLVM_ABI unsigned ComputeNumSignBits(SDValue Op, unsigned Depth=0) const
Return the number of times the sign bit of the register is replicated into the other bits.
SDValue getTargetBlockAddress(const BlockAddress *BA, EVT VT, int64_t Offset=0, unsigned TargetFlags=0)
LLVM_ABI SDValue getVectorIdxConstant(uint64_t Val, const SDLoc &DL, bool isTarget=false)
LLVM_ABI void ReplaceAllUsesOfValueWith(SDValue From, SDValue To)
Replace any uses of From with To, leaving uses of other values produced by From.getNode() alone.
MachineFunction & getMachineFunction() const
SDValue getPOISON(EVT VT)
Return a POISON node. POISON does not have a useful SDLoc.
LLVM_ABI SDValue getFrameIndex(int FI, EVT VT, bool isTarget=false)
LLVM_ABI KnownBits computeKnownBits(SDValue Op, unsigned Depth=0) const
Determine which bits of Op are known to be either zero or one and return them in Known.
LLVM_ABI 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...
LLVM_ABI bool MaskedValueIsZero(SDValue Op, const APInt &Mask, unsigned Depth=0) const
Return true if 'Op & Mask' is known to be zero.
SDValue getObjectPtrOffset(const SDLoc &SL, SDValue Ptr, TypeSize Offset)
Create an add instruction with appropriate flags when used for addressing some offset of an object.
LLVMContext * getContext() const
const SDValue & setRoot(SDValue N)
Set the current root tag of the SelectionDAG.
LLVM_ABI SDNode * UpdateNodeOperands(SDNode *N, SDValue Op)
Mutate the specified node in-place to have the specified operands.
SDValue getEntryNode() const
Return the token chain corresponding to the entry of the function.
LLVM_ABI std::pair< SDValue, SDValue > SplitScalar(const SDValue &N, const SDLoc &DL, const EVT &LoVT, const EVT &HiVT)
Split the scalar node with EXTRACT_ELEMENT using the provided VTs and return the low/high part.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
This class is used to represent ISD::STORE nodes.
const SDValue & getBasePtr() const
const SDValue & getValue() const
Represent a constant reference to a string, i.e.
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...
void setMaxDivRemBitWidthSupported(unsigned SizeInBits)
Set the size in bits of the maximum div/rem the backend supports.
bool PredictableSelectIsExpensive
Tells the code generator that select is more expensive than a branch if the branch is usually predict...
virtual bool shouldReduceLoadWidth(SDNode *Load, ISD::LoadExtType ExtTy, EVT NewVT, std::optional< unsigned > ByteOffset=std::nullopt) const
Return true if it is profitable to reduce a load to a smaller type.
unsigned MaxStoresPerMemcpyOptSize
Likewise for functions with the OptSize attribute.
const TargetMachine & getTargetMachine() const
virtual unsigned getNumRegistersForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT) const
Certain targets require unusual breakdowns of certain types.
unsigned MaxGluedStoresPerMemcpy
Specify max number of store instructions to glue in inlined memcpy.
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...
void addBypassSlowDiv(unsigned int SlowBitWidth, unsigned int FastBitWidth)
Tells the code generator which bitwidths to bypass.
void setMaxLargeFPConvertBitWidthSupported(unsigned SizeInBits)
Set the size in bits of the maximum fp to/from int conversion the backend supports.
void setMaxAtomicSizeInBitsSupported(unsigned SizeInBits)
Set the maximum atomic operation size supported by the backend.
SelectSupportKind
Enum that describes what type of support for selects the target has.
virtual bool allowsMisalignedMemoryAccesses(EVT, unsigned AddrSpace=0, Align Alignment=Align(1), MachineMemOperand::Flags Flags=MachineMemOperand::MONone, unsigned *=nullptr) const
Determine if the target supports unaligned memory accesses.
unsigned MaxStoresPerMemsetOptSize
Likewise for functions with the OptSize attribute.
EVT getShiftAmountTy(EVT LHSTy, const DataLayout &DL) const
Returns the type for the shift amount of a shift opcode.
unsigned MaxStoresPerMemmove
Specify maximum number of store instructions per memmove call.
virtual EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context, EVT VT) const
Return the ValueType of the result of SETCC operations.
unsigned MaxStoresPerMemmoveOptSize
Likewise for functions with the OptSize attribute.
bool isTypeLegal(EVT VT) const
Return true if the target has native support for the specified value type.
void setSupportsUnalignedAtomics(bool UnalignedSupported)
Sets whether unaligned atomic operations are supported.
bool isOperationLegal(unsigned Op, EVT VT) const
Return true if the specified operation is legal on this target.
unsigned MaxStoresPerMemset
Specify maximum number of store instructions per memset call.
void setTruncStoreAction(MVT ValVT, MVT MemVT, LegalizeAction Action)
Indicate that the specified truncating store does not work with the specified type and indicate what ...
void setMinCmpXchgSizeInBits(unsigned SizeInBits)
Sets the minimum cmpxchg or ll/sc size supported by the backend.
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/...
void setTargetDAGCombine(ArrayRef< ISD::NodeType > NTs)
Targets should invoke this method for each target independent node that they want to provide a custom...
void setLoadExtAction(unsigned ExtType, MVT ValVT, MVT MemVT, LegalizeAction Action)
Indicate that the specified load with extension does not work with the specified type and indicate wh...
unsigned GatherAllAliasesMaxDepth
Depth that GatherAllAliases should continue looking for chain dependencies when trying to find a more...
NegatibleCost
Enum that specifies when a float negation is beneficial.
bool allowsMemoryAccessForAlignment(LLVMContext &Context, const DataLayout &DL, EVT VT, unsigned AddrSpace=0, Align Alignment=Align(1), MachineMemOperand::Flags Flags=MachineMemOperand::MONone, unsigned *Fast=nullptr) const
This function returns true if the memory access is aligned or if the target allows this specific unal...
unsigned MaxStoresPerMemcpy
Specify maximum number of store instructions per memcpy call.
void setSchedulingPreference(Sched::Preference Pref)
Specify the target scheduling preference.
void setJumpIsExpensive(bool isExpensive=true)
Tells the code generator not to expand logic operations on comparison predicates into separate sequen...
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
SDValue scalarizeVectorStore(StoreSDNode *ST, SelectionDAG &DAG) const
SDValue SimplifyMultipleUseDemandedBits(SDValue Op, const APInt &DemandedBits, const APInt &DemandedElts, SelectionDAG &DAG, unsigned Depth=0) const
More limited version of SimplifyDemandedBits that can be used to "lookthrough" ops that don't contrib...
SDValue expandUnalignedStore(StoreSDNode *ST, SelectionDAG &DAG) const
Expands an unaligned store to 2 half-size stores for integer values, and possibly more for vectors.
bool ShrinkDemandedConstant(SDValue Op, const APInt &DemandedBits, const APInt &DemandedElts, TargetLoweringOpt &TLO) const
Check to see if the specified operand of the specified instruction is a constant integer.
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.
virtual SDValue getNegatedExpression(SDValue Op, SelectionDAG &DAG, bool LegalOps, bool OptForSize, NegatibleCost &Cost, unsigned Depth=0) const
Return the newly negated expression if the cost is not expensive and set the cost in Cost to indicate...
std::pair< SDValue, SDValue > scalarizeVectorLoad(LoadSDNode *LD, SelectionDAG &DAG) const
Turn load of vector type into a load of the individual elements.
bool SimplifyDemandedBits(SDValue Op, const APInt &DemandedBits, const APInt &DemandedElts, KnownBits &Known, TargetLoweringOpt &TLO, unsigned Depth=0, bool AssumeSingleUse=false) const
Look at Op.
TargetLowering(const TargetLowering &)=delete
virtual bool canCreateUndefOrPoisonForTargetNode(SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG, UndefPoisonKind Kind, bool ConsiderFlags, unsigned Depth) const
Return true if Op can create undef or poison from non-undef & non-poison operands.
Primary interface to the complete machine description for the target machine.
TargetSubtargetInfo - Generic base class for all target subtargets.
static constexpr TypeSize getFixed(ScalarTy ExactSize)
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM_ABI unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
LLVM Value Representation.
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ CONSTANT_ADDRESS_32BIT
Address space for 32-bit constant memory.
@ BARRIER
Address space for modeling barrier IDs as addresses.
@ REGION_ADDRESS
Address space for region memory. (GDS)
@ LOCAL_ADDRESS
Address space for local memory.
@ CONSTANT_ADDRESS
Address space for constant memory (VTX2).
@ GLOBAL_ADDRESS
Address space for global memory (RAT0, VTX0).
bool isIntrinsicAlwaysUniform(unsigned IntrID)
TargetExtType * isNamedBarrier(const GlobalVariable &GV)
std::optional< APFloat > evaluateRcp(const APFloat &Val)
Evaluate the constant-folded result of v_rcp for Val, accounting for the hardware's denormal flushing...
bool isUniformMMO(const MachineMemOperand *MMO)
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ AMDGPU_CS
Used for Mesa/AMDPAL compute shaders.
@ AMDGPU_VS
Used for Mesa vertex shaders, or AMDPAL last shader stage before rasterization (vertex shader if tess...
@ AMDGPU_KERNEL
Used for AMDGPU code object kernels.
@ AMDGPU_Gfx
Used for AMD graphics targets.
@ AMDGPU_CS_ChainPreserve
Used on AMDGPUs to give the middle-end more control over argument placement.
@ AMDGPU_HS
Used for Mesa/AMDPAL hull shaders (= tessellation control shaders).
@ AMDGPU_GS
Used for Mesa/AMDPAL geometry shaders.
@ AMDGPU_CS_Chain
Used on AMDGPUs to give the middle-end more control over argument placement.
@ AMDGPU_PS
Used for Mesa/AMDPAL pixel shaders.
@ Cold
Attempts to make code in the caller as efficient as possible under the assumption that the call is no...
@ SPIR_KERNEL
Used for SPIR kernel functions.
@ Fast
Attempts to make calls as fast as possible (e.g.
@ AMDGPU_ES
Used for AMDPAL shader stage before geometry shader if geometry is in use.
@ AMDGPU_LS
Used for AMDPAL vertex shader if tessellation is in use.
@ C
The default llvm calling convention, compatible with C.
NodeType
ISD::NodeType enum - This enum defines the target-independent operators for a SelectionDAG.
@ SETCC
SetCC operator - This evaluates to a true value iff the condition is true.
@ SMUL_LOHI
SMUL_LOHI/UMUL_LOHI - Multiply two integers of type iN, producing a signed/unsigned value of type i[2...
@ INSERT_SUBVECTOR
INSERT_SUBVECTOR(VECTOR1, VECTOR2, IDX) - Returns a vector with VECTOR2 inserted into VECTOR1.
@ BSWAP
Byte Swap and Counting operators.
@ ATOMIC_STORE
OUTCHAIN = ATOMIC_STORE(INCHAIN, val, ptr) This corresponds to "store atomic" instruction.
@ ADDC
Carry-setting nodes for multiple precision addition and subtraction.
@ FMAD
FMAD - Perform a * b + c, while getting the same result as the separately rounded operations.
@ ADD
Simple integer binary arithmetic operators.
@ LOAD
LOAD and STORE have token chains as their first operand, then the same operands as an LLVM load/store...
@ ANY_EXTEND
ANY_EXTEND - Used for integer types. The high bits are undefined.
@ FMA
FMA - Perform a * b + c with no intermediate rounding step.
@ SINT_TO_FP
[SU]INT_TO_FP - These operators convert integers (whose interpreted sign depends on the first letter)...
@ CONCAT_VECTORS
CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of vector type with the same length ...
@ FADD
Simple binary floating point operators.
@ ABS
ABS - Determine the unsigned absolute value of a signed integer value of the same bitwidth.
@ SDIVREM
SDIVREM/UDIVREM - Divide two integers and produce both a quotient and remainder result.
@ FP16_TO_FP
FP16_TO_FP, FP_TO_FP16 - These operators are used to perform promotions and truncation for half-preci...
@ BITCAST
BITCAST - This operator converts between integer, vector and FP values, as if the value was stored to...
@ BUILD_PAIR
BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways.
@ FLDEXP
FLDEXP - ldexp, inspired by libm (op0 * 2**op1).
@ SIGN_EXTEND
Conversion operators.
@ FNEG
Perform various unary floating-point operations inspired by libm.
@ BRIND
BRIND - Indirect branch.
@ BR_JT
BR_JT - Jumptable branch.
@ FCANONICALIZE
Returns platform specific canonical encoding of a floating point number.
@ IS_FPCLASS
Performs a check of floating point class property, defined by IEEE-754.
@ SELECT
Select(COND, TRUEVAL, FALSEVAL).
@ ATOMIC_LOAD
Val, OUTCHAIN = ATOMIC_LOAD(INCHAIN, ptr) This corresponds to "load atomic" instruction.
@ EXTRACT_ELEMENT
EXTRACT_ELEMENT - This is used to get the lower or upper (determined by a Constant,...
@ CTLS
Count leading redundant sign bits.
@ MULHU
MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing an unsigned/signed value of...
@ SHL
Shift and rotation operations.
@ VECTOR_SHUFFLE
VECTOR_SHUFFLE(VEC1, VEC2) - Returns a vector, of the same type as VEC1/VEC2.
@ EXTRACT_SUBVECTOR
EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR.
@ FMINNUM_IEEE
FMINNUM_IEEE/FMAXNUM_IEEE - Perform floating-point minimumNumber or maximumNumber on two values,...
@ EntryToken
EntryToken - This is the marker used to indicate the start of a region.
@ EXTRACT_VECTOR_ELT
EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR identified by the (potentially...
@ CopyToReg
CopyToReg - This node has three operands: a chain, a register number to set to this value,...
@ ZERO_EXTEND
ZERO_EXTEND - Used for integer types, zeroing the new bits.
@ SELECT_CC
Select with condition operator - This selects between a true value and a false value (ops #2 and #3) ...
@ FMINNUM
FMINNUM/FMAXNUM - Perform floating-point minimum maximum on two values, following IEEE-754 definition...
@ DYNAMIC_STACKALLOC
DYNAMIC_STACKALLOC - Allocate some number of bytes on the stack aligned to a specified boundary.
@ SIGN_EXTEND_INREG
SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to sign extend a small value in ...
@ SMIN
[US]{MIN/MAX} - Binary minimum or maximum of signed or unsigned integers.
@ FP_EXTEND
X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
@ VSELECT
Select with a vector condition (op #0) and two vector operands (ops #1 and #2), returning a vector re...
@ UADDO_CARRY
Carry-using nodes for multiple precision addition and subtraction.
@ INLINEASM_BR
INLINEASM_BR - Branching version of inline asm. Used by asm-goto.
@ FMINIMUM
FMINIMUM/FMAXIMUM - NaN-propagating minimum/maximum that also treat -0.0 as less than 0....
@ FP_TO_SINT
FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
@ AND
Bitwise operators - logical and, logical or, logical xor.
@ TRAP
TRAP - Trapping instruction.
@ INTRINSIC_WO_CHAIN
RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...) This node represents a target intrinsic fun...
@ ADDE
Carry-using nodes for multiple precision addition and subtraction.
@ INSERT_VECTOR_ELT
INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element at IDX replaced with VAL.
@ TokenFactor
TokenFactor - This node takes multiple tokens as input and produces a single token result.
@ CTTZ_ZERO_POISON
Bit counting operators with a poisoned result for zero inputs.
@ FFREXP
FFREXP - frexp, extract fractional and exponent component of a floating-point value.
@ FP_ROUND
X = FP_ROUND(Y, TRUNC) - Rounding 'Y' from a larger floating point type down to the precision of the ...
@ ADDRSPACECAST
ADDRSPACECAST - This operator converts between pointers of different address spaces.
@ INLINEASM
INLINEASM - Represents an inline asm block.
@ FP_TO_SINT_SAT
FP_TO_[US]INT_SAT - Convert floating point value in operand 0 to a signed or unsigned scalar integer ...
@ TRUNCATE
TRUNCATE - Completely drop the high bits.
@ AssertSext
AssertSext, AssertZext - These nodes record if a register contains a value that has already been zero...
@ FCOPYSIGN
FCOPYSIGN(X, Y) - Return the value of X with the sign of Y.
@ FMINIMUMNUM
FMINIMUMNUM/FMAXIMUMNUM - minimumnum/maximumnum that is same with FMINNUM_IEEE and FMAXNUM_IEEE besid...
@ INTRINSIC_W_CHAIN
RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...) This node represents a target in...
@ BUILD_VECTOR
BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a fixed-width vector with the specified,...
bool isNormalStore(const SDNode *N)
Returns true if the specified node is a non-truncating and unindexed store.
LLVM_ABI CondCode getSetCCInverse(CondCode Operation, EVT Type)
Return the operation corresponding to !(X op Y), where 'op' is a valid SetCC operation.
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out,...
LoadExtType
LoadExtType enum - This enum defines the three variants of LOADEXT (load with extension).
bool isNormalLoad(const SDNode *N)
Returns true if the specified node is a non-extending and unindexed load.
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
LLVM_ABI bool isNullConstant(SDValue V)
Returns true if V is a constant integer zero.
@ Known
Known to have no common set bits.
LLVM_ABI void ComputeValueVTs(const TargetLowering &TLI, const DataLayout &DL, Type *Ty, SmallVectorImpl< EVT > &ValueVTs, SmallVectorImpl< EVT > *MemVTs=nullptr, SmallVectorImpl< TypeSize > *Offsets=nullptr, TypeSize StartingOffset=TypeSize::getZero())
ComputeValueVTs - Given an LLVM IR type, compute a sequence of EVTs that represent all the individual...
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
bool CCAssignFn(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, Type *OrigTy, CCState &State)
CCAssignFn - This function assigns a location for Val, updating State to reflect the change.
@ Load
The value being inserted comes from a load (InsertElement only).
@ Store
The extracted value is stored (ExtractElement only).
SDValue peekFPSignOps(SDValue Val)
Strip fabs/fneg/fcopysign from a value to get the underlying source.
LLVM_ABI ConstantFPSDNode * isConstOrConstSplatFP(SDValue N, bool AllowUndefs=false)
Returns the SDNode if it is a constant splat BuildVector or constant float.
uint64_t PowerOf2Ceil(uint64_t A)
Returns the power of two which is greater than or equal to the given value.
int countr_zero(T Val)
Count number of 0's from the least significant bit to the most stopping at the first 1.
int countl_zero(T Val)
Count number of 0's from the most significant bit to the least stopping at the first 1.
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
FPClassTest
Floating-point class tests, supported by 'is_fpclass' intrinsic.
constexpr uint32_t Hi_32(uint64_t Value)
Return the high 32 bits of a 64 bit value.
constexpr uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
constexpr bool isUInt(uint64_t x)
Checks if an unsigned integer fits into the given bit width.
constexpr uint32_t Lo_32(uint64_t Value)
Return the low 32 bits of a 64 bit value.
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
To bit_cast(const From &from) noexcept
@ Mul
Product of integers.
@ Fast
Assign the register banks as fast as possible (default).
DWARFExpression::Operation Op
LLVM_ABI ConstantSDNode * isConstOrConstSplat(SDValue N, bool AllowUndefs=false, bool AllowTruncation=false)
Returns the SDNode if it is a constant splat BuildVector or constant int.
constexpr unsigned BitWidth
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI bool isOneConstant(SDValue V)
Returns true if V is a constant integer one.
UndefPoisonKind
Enumeration to track whether we are interested in Undef, Poison, or both.
Align commonAlignment(Align A, uint64_t Offset)
Returns the alignment that satisfies both alignments.
static cl::opt< unsigned > CostThreshold("dfa-cost-threshold", cl::desc("Maximum cost accepted for the transformation"), cl::Hidden, cl::init(50))
APFloat neg(APFloat X)
Returns the negated value of the argument.
unsigned Log2(Align A)
Returns the log2 of the alignment.
LLVM_ABI bool isAllOnesConstant(SDValue V)
Returns true if V is an integer constant with all bits set.
MCRegisterClass TargetRegisterClass
LLVM_ABI void reportFatalUsageError(Error Err)
Report a fatal error that does not indicate a bug in LLVM.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
This struct is a compact representation of a valid (non-zero power of two) alignment.
MCRegister getRegister() const
unsigned getStackOffset() const
DenormalModeKind Input
Denormal treatment kind for floating point instruction inputs in the default floating-point environme...
@ PreserveSign
The sign of a flushed-to-zero number is preserved in the sign of 0.
constexpr bool inputsAreZero() const
Return true if input denormals must be implicitly treated as 0.
static constexpr DenormalMode getPreserveSign()
TypeSize getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
EVT getPow2VectorType(LLVMContext &Context) const
Widens the length of the given vector EVT up to the nearest power of 2 and returns that type.
bool isSimple() const
Test if the given EVT is simple (as opposed to being extended).
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 changeTypeToInteger() const
Return the type converted to an equivalently sized integer or vector with integer element type.
bool bitsGT(EVT VT) const
Return true if this has more bits than VT.
bool isFloatingPoint() const
Return true if this is a FP or a vector FP type.
TypeSize getSizeInBits() const
Return the size of the specified value type in bits.
bool isByteSized() const
Return true if the bit size is a multiple of 8.
uint64_t getScalarSizeInBits() const
EVT getHalfSizedIntegerVT(LLVMContext &Context) const
Finds the smallest simple value type that is greater than or equal to half the width of this EVT.
bool isPow2VectorType() const
Returns true if the given vector is a power of 2.
TypeSize getStoreSizeInBits() const
Return the number of bits overwritten by a store of the specified value type.
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
static EVT getIntegerVT(LLVMContext &Context, unsigned BitWidth)
Returns the EVT that represents an integer with the given number of bits.
uint64_t getFixedSizeInBits() const
Return the size of the specified fixed width value type in bits.
EVT getRoundIntegerType(LLVMContext &Context) const
Rounds the bit-width of the given integer EVT up to the nearest power of two (and at least to eight),...
bool isVector() const
Return true if this is a vector value type.
EVT getScalarType() const
If this is a vector type, return the element type, otherwise return this.
bool bitsGE(EVT VT) const
Return true if this has no less bits than VT.
EVT getVectorElementType() const
Given a vector type, return the type of each element.
bool isExtended() const
Test if the given EVT is extended (as opposed to being simple).
EVT changeElementType(LLVMContext &Context, EVT EltVT) const
Return a VT for a type whose attributes match ourselves with the exception of the element type that i...
LLVM_ABI const fltSemantics & getFltSemantics() const
Returns an APFloat semantics tag appropriate for the value type.
unsigned getVectorNumElements() const
Given a vector type, return the number of elements it contains.
bool bitsLE(EVT VT) const
Return true if this has no more bits than VT.
bool isInteger() const
Return true if this is an integer or a vector integer type.
bool isUnknown() const
Returns true if we don't know any bits.
KnownBits trunc(unsigned BitWidth) const
Return known bits for a truncation of the value we're tracking.
KnownBits zext(unsigned BitWidth) const
Return known bits for a zero extension of the value we're tracking.
unsigned countMaxActiveBits() const
Returns the maximum number of bits needed to represent all possible unsigned values with these known ...
KnownBits intersectWith(const KnownBits &RHS) const
Returns KnownBits information that is known to be true for both this and RHS.
KnownBits sext(unsigned BitWidth) const
Return known bits for a sign extension of the value we're tracking.
unsigned countMinLeadingZeros() const
Returns the minimum number of leading zero bits.
bool isNegative() const
Returns true if this value is known to be negative.
static LLVM_ABI KnownBits mul(const KnownBits &LHS, const KnownBits &RHS, bool NoUndefSelfMultiply=false)
Compute known bits resulting from multiplying LHS and RHS.
bool signBitIsZeroOrNaN() const
Return true if the sign bit must be 0, ignoring the sign of nans.
This class contains a discriminated union of information about pointers in memory operands,...
LLVM_ABI bool isDereferenceable(unsigned Size, LLVMContext &C, const DataLayout &DL) const
Return true if memory region [V, V+Offset+Size) is known to be dereferenceable.
static LLVM_ABI MachinePointerInfo getStack(MachineFunction &MF, int64_t Offset, uint8_t ID=0)
Stack pointer relative access.
MachinePointerInfo getWithOffset(int64_t O) const
These are IR-level optimization flags that may be propagated to SDNodes.
void setAllowContract(bool b)
bool hasNoSignedZeros() const
This represents a list of ValueType's that has been intern'd by a SelectionDAG.
DenormalMode FP32Denormals
If this is set, neither input or output denormals are flushed for most f32 instructions.
This structure contains all information that is necessary for lowering calls.
SmallVector< ISD::InputArg, 32 > Ins
bool isBeforeLegalizeOps() const
CombineLevel getDAGCombineLevel()
LLVM_ABI void AddToWorklist(SDNode *N)
bool isCalledByLegalizer() const
bool isBeforeLegalize() const
LLVM_ABI SDValue CombineTo(SDNode *N, ArrayRef< SDValue > To, bool AddTo=true)
LLVM_ABI void CommitTargetLoweringOpt(const TargetLoweringOpt &TLO)
A convenience struct that encapsulates a DAG, and two SDValues for returning information from TargetL...