24#include "llvm/IR/IntrinsicsDirectX.h"
33#define DEBUG_TYPE "dxil-intrinsic-expansion"
48 if (IsRaw && M->getTargetTriple().getDXILVersion() >
VersionTuple(1, 2))
57 if (M->getTargetTriple().getDXILVersion() >=
VersionTuple(1, 9))
62 if (!ValTy->getScalarType()->isHalfTy())
72 ConstantInt::get(IType, 0x7c00))
73 : ConstantInt::get(IType, 0x7c00);
80 ConstantInt::get(IType, 0xfc00))
81 : ConstantInt::get(IType, 0xfc00);
83 Value *IVal = Builder.CreateBitCast(Val, PosInf->
getType());
84 Value *B1 = Builder.CreateICmpEQ(IVal, PosInf);
85 Value *B2 = Builder.CreateICmpEQ(IVal, NegInf);
86 Value *B3 = Builder.CreateOr(B1, B2);
92 if (M->getTargetTriple().getDXILVersion() >=
VersionTuple(1, 9))
97 if (!ValTy->getScalarType()->isHalfTy())
108 ConstantInt::get(IType, 0x7c00))
109 : ConstantInt::get(IType, 0x7c00);
115 ConstantInt::get(IType, 0x3ff))
116 : ConstantInt::get(IType, 0x3ff);
123 ConstantInt::get(IType, 0))
124 : ConstantInt::get(IType, 0);
126 Value *IVal = Builder.CreateBitCast(Val, ExpBitMask->
getType());
127 Value *Exp = Builder.CreateAnd(IVal, ExpBitMask);
128 Value *B1 = Builder.CreateICmpEQ(Exp, ExpBitMask);
130 Value *Sig = Builder.CreateAnd(IVal, SigBitMask);
131 Value *B2 = Builder.CreateICmpNE(Sig, Zero);
132 Value *B3 = Builder.CreateAnd(B1, B2);
138 if (M->getTargetTriple().getDXILVersion() >=
VersionTuple(1, 9))
143 if (!ValTy->getScalarType()->isHalfTy())
154 ConstantInt::get(IType, 0x7c00))
155 : ConstantInt::get(IType, 0x7c00);
157 Value *IVal = Builder.CreateBitCast(Val, ExpBitMask->
getType());
158 Value *Exp = Builder.CreateAnd(IVal, ExpBitMask);
159 Value *B1 = Builder.CreateICmpNE(Exp, ExpBitMask);
165 if (M->getTargetTriple().getDXILVersion() >=
VersionTuple(1, 9))
170 if (!ValTy->getScalarType()->isHalfTy())
181 ConstantInt::get(IType, 0x7c00))
182 : ConstantInt::get(IType, 0x7c00);
188 ConstantInt::get(IType, 0))
189 : ConstantInt::get(IType, 0);
191 Value *IVal = Builder.CreateBitCast(Val, ExpBitMask->
getType());
192 Value *Exp = Builder.CreateAnd(IVal, ExpBitMask);
193 Value *NotAllZeroes = Builder.CreateICmpNE(Exp, Zero);
194 Value *NotAllOnes = Builder.CreateICmpNE(Exp, ExpBitMask);
195 Value *B1 = Builder.CreateAnd(NotAllZeroes, NotAllOnes);
200 switch (
F.getIntrinsicID()) {
201 case Intrinsic::assume:
203 case Intrinsic::atan2:
204 case Intrinsic::fshl:
205 case Intrinsic::fshr:
207 case Intrinsic::is_fpclass:
209 case Intrinsic::log10:
211 case Intrinsic::powi:
212 case Intrinsic::dx_all:
213 case Intrinsic::dx_any:
214 case Intrinsic::dx_cross:
215 case Intrinsic::dx_uclamp:
216 case Intrinsic::dx_sclamp:
217 case Intrinsic::dx_nclamp:
218 case Intrinsic::dx_degrees:
219 case Intrinsic::dx_isinf:
220 case Intrinsic::dx_isnan:
221 case Intrinsic::dx_lerp:
222 case Intrinsic::dx_normalize:
223 case Intrinsic::dx_fdot:
224 case Intrinsic::dx_sdot:
225 case Intrinsic::dx_udot:
226 case Intrinsic::dx_sign:
227 case Intrinsic::dx_step:
228 case Intrinsic::dx_radians:
229 case Intrinsic::usub_sat:
230 case Intrinsic::vector_reduce_add:
231 case Intrinsic::vector_reduce_fadd:
233 case Intrinsic::dx_resource_load_rawbuffer:
235 F.getParent(),
F.getReturnType()->getStructElementType(0),
237 case Intrinsic::dx_resource_load_typedbuffer:
239 F.getParent(),
F.getReturnType()->getStructElementType(0),
241 case Intrinsic::dx_resource_store_rawbuffer:
243 F.getParent(),
F.getFunctionType()->getParamType(3),
true);
244 case Intrinsic::dx_resource_store_typedbuffer:
246 F.getParent(),
F.getFunctionType()->getParamType(2),
false);
254 Type *Ty =
A->getType();
258 Value *Cmp = Builder.CreateICmpULT(
A,
B,
"usub.cmp");
259 Value *
Sub = Builder.CreateSub(
A,
B,
"usub.sub");
260 Value *Zero = ConstantInt::get(Ty, 0);
261 return Builder.CreateSelect(Cmp, Zero,
Sub,
"usub.sat");
265 assert(IntrinsicId == Intrinsic::vector_reduce_add ||
266 IntrinsicId == Intrinsic::vector_reduce_fadd);
269 bool IsFAdd = (IntrinsicId == Intrinsic::vector_reduce_fadd);
272 Type *Ty =
X->getType();
274 unsigned XVecSize = XVec->getNumElements();
275 Value *Sum = Builder.CreateExtractElement(
X,
static_cast<uint64_t>(0));
281 Sum = Builder.CreateFAdd(Sum, StartValue);
285 for (
unsigned I = 1;
I < XVecSize;
I++) {
286 Value *Elt = Builder.CreateExtractElement(
X,
I);
288 Sum = Builder.CreateFAdd(Sum, Elt);
290 Sum = Builder.CreateAdd(Sum, Elt);
299 Type *Ty =
X->getType();
305 ConstantInt::get(EltTy, 0))
306 : ConstantInt::get(EltTy, 0);
307 auto *V = Builder.CreateSub(Zero,
X);
308 return Builder.CreateIntrinsic(Ty, Intrinsic::smax, {
X, V},
nullptr,
322 Value *op0_x = Builder.CreateExtractElement(op0, (
uint64_t)0,
"x0");
323 Value *op0_y = Builder.CreateExtractElement(op0, 1,
"x1");
324 Value *op0_z = Builder.CreateExtractElement(op0, 2,
"x2");
326 Value *op1_x = Builder.CreateExtractElement(op1, (
uint64_t)0,
"y0");
327 Value *op1_y = Builder.CreateExtractElement(op1, 1,
"y1");
328 Value *op1_z = Builder.CreateExtractElement(op1, 2,
"y2");
331 Value *xy = Builder.CreateFMul(x0, y1);
332 Value *yx = Builder.CreateFMul(y0, x1);
333 return Builder.CreateFSub(xy, yx, Orig->
getName());
336 Value *yz_zy = MulSub(op0_y, op0_z, op1_y, op1_z);
337 Value *zx_xz = MulSub(op0_z, op0_x, op1_z, op1_x);
338 Value *xy_yx = MulSub(op0_x, op0_y, op1_x, op1_y);
341 cross = Builder.CreateInsertElement(cross, yz_zy, (
uint64_t)0);
342 cross = Builder.CreateInsertElement(cross, zx_xz, 1);
343 cross = Builder.CreateInsertElement(cross, xy_yx, 2);
351 Type *ATy =
A->getType();
352 [[maybe_unused]]
Type *BTy =
B->getType();
362 int NumElts = AVec->getNumElements();
365 DotIntrinsic = Intrinsic::dx_dot2;
368 DotIntrinsic = Intrinsic::dx_dot3;
371 DotIntrinsic = Intrinsic::dx_dot4;
375 "Invalid dot product input vector: length is outside 2-4");
380 for (
int I = 0;
I < NumElts; ++
I)
381 Args.push_back(Builder.CreateExtractElement(
A, Builder.getInt32(
I)));
382 for (
int I = 0;
I < NumElts; ++
I)
383 Args.push_back(Builder.CreateExtractElement(
B, Builder.getInt32(
I)));
384 return Builder.CreateIntrinsic(ATy->
getScalarType(), DotIntrinsic, Args,
399 assert(DotIntrinsic == Intrinsic::dx_sdot ||
400 DotIntrinsic == Intrinsic::dx_udot);
403 Type *ATy =
A->getType();
404 [[maybe_unused]]
Type *BTy =
B->getType();
414 Intrinsic::ID MadIntrinsic = DotIntrinsic == Intrinsic::dx_sdot
416 : Intrinsic::dx_umad;
419 Result = Builder.CreateMul(Elt0, Elt1);
420 for (
unsigned I = 1;
I < AVec->getNumElements();
I++) {
421 Elt0 = Builder.CreateExtractElement(
A,
I);
422 Elt1 = Builder.CreateExtractElement(
B,
I);
423 Result = Builder.CreateIntrinsic(Result->getType(), MadIntrinsic,
433 Type *Ty =
X->getType();
441 Value *NewX = Builder.CreateFMul(Log2eConst,
X);
443 Builder.CreateIntrinsic(Ty, Intrinsic::exp2, {NewX},
nullptr,
"dx.exp2");
455 switch (TCI->getZExtValue()) {
469 Type *FTy =
F->getType();
470 unsigned FNumElem = 0;
476 Type *ElemTy = FVecTy->getElementType();
477 FNumElem = FVecTy->getNumElements();
478 BitWidth = ElemTy->getPrimitiveSizeInBits();
485 Value *FBitCast = Builder.CreateBitCast(
F, BitCastTy);
486 switch (TCI->getZExtValue()) {
492 Value *NegZeroSplat = Builder.CreateVectorSplat(FNumElem, NegZero);
494 Builder.CreateICmpEQ(FBitCast, NegZeroSplat,
"is.fpclass.negzero");
496 RetVal = Builder.CreateICmpEQ(FBitCast, NegZero,
"is.fpclass.negzero");
508 Type *Ty =
X->getType();
513 if (IntrinsicId == Intrinsic::dx_any)
514 return Builder.CreateOr(Result, Elt);
515 assert(IntrinsicId == Intrinsic::dx_all);
516 return Builder.CreateAnd(Result, Elt);
519 Value *Result =
nullptr;
520 if (!Ty->isVectorTy()) {
522 ? Builder.CreateFCmpUNE(
X, ConstantFP::get(EltTy, 0))
523 : Builder.CreateICmpNE(
X, ConstantInt::get(EltTy, 0));
528 ? Builder.CreateFCmpUNE(
531 ConstantFP::get(EltTy, 0)))
532 : Builder.CreateICmpNE(
535 ConstantInt::get(EltTy, 0)));
536 Result = Builder.CreateExtractElement(
Cond, (
uint64_t)0);
537 for (
unsigned I = 1;
I < XVec->getNumElements();
I++) {
538 Value *Elt = Builder.CreateExtractElement(
Cond,
I);
539 Result = ApplyOp(IntrinsicId, Result, Elt);
550 auto *V = Builder.CreateFSub(
Y,
X);
551 V = Builder.CreateFMul(S, V);
552 return Builder.CreateFAdd(
X, V,
"dx.lerp");
559 Type *Ty =
X->getType();
565 ConstantFP::get(EltTy, LogConstVal))
566 : ConstantFP::get(EltTy, LogConstVal);
568 Builder.CreateIntrinsic(Ty, Intrinsic::log2, {
X},
nullptr,
"elt.log2");
571 return Builder.CreateFMul(Ln2Const, Log2Call);
588 const APFloat &fpVal = constantFP->getValueAPF();
592 return Builder.CreateFDiv(
X,
X);
600 const APFloat &fpVal = constantFP->getValueAPF();
605 Value *Multiplicand = Builder.CreateIntrinsic(EltTy, Intrinsic::dx_rsqrt,
607 nullptr,
"dx.rsqrt");
609 Value *MultiplicandVec =
610 Builder.CreateVectorSplat(XVec->getNumElements(), Multiplicand);
611 return Builder.CreateFMul(
X, MultiplicandVec);
617 Type *Ty =
X->getType();
621 Value *Tan = Builder.CreateFDiv(
Y,
X);
624 Builder.CreateIntrinsic(Ty, Intrinsic::atan, {Tan},
nullptr,
"Elt.Atan");
632 Constant *Zero = ConstantFP::get(Ty, 0);
633 Value *AtanAddPi = Builder.CreateFAdd(Atan, Pi);
634 Value *AtanSubPi = Builder.CreateFSub(Atan, Pi);
637 Value *Result = Atan;
638 Value *XLt0 = Builder.CreateFCmpOLT(
X, Zero);
639 Value *XEq0 = Builder.CreateFCmpOEQ(
X, Zero);
640 Value *YGe0 = Builder.CreateFCmpOGE(
Y, Zero);
641 Value *YLt0 = Builder.CreateFCmpOLT(
Y, Zero);
644 Value *XLt0AndYGe0 = Builder.CreateAnd(XLt0, YGe0);
645 Result = Builder.CreateSelect(XLt0AndYGe0, AtanAddPi, Result);
648 Value *XLt0AndYLt0 = Builder.CreateAnd(XLt0, YLt0);
649 Result = Builder.CreateSelect(XLt0AndYLt0, AtanSubPi, Result);
652 Value *XEq0AndYLt0 = Builder.CreateAnd(XEq0, YLt0);
653 Result = Builder.CreateSelect(XEq0AndYLt0, NegHalfPi, Result);
656 Value *XEq0AndYGe0 = Builder.CreateAnd(XEq0, YGe0);
657 Result = Builder.CreateSelect(XEq0AndYGe0, HalfPi, Result);
662template <
bool LeftFunnel>
671 unsigned BitWidth = Ty->getScalarSizeInBits();
673 "Can't use Mask to compute modulo and inverse");
688 Constant *Mask = ConstantInt::get(Ty, Ty->getScalarSizeInBits() - 1);
693 Value *MaskedShift = Builder.CreateAnd(Shift, Mask);
698 Value *NotShift = Builder.CreateNot(Shift);
699 Value *InverseShift = Builder.CreateAnd(NotShift, Mask);
701 Constant *One = ConstantInt::get(Ty, 1);
706 ShiftedA = Builder.CreateShl(
A, MaskedShift);
707 Value *ShiftB1 = Builder.CreateLShr(
B, One);
708 ShiftedB = Builder.CreateLShr(ShiftB1, InverseShift);
710 Value *ShiftA1 = Builder.CreateShl(
A, One);
711 ShiftedA = Builder.CreateShl(ShiftA1, InverseShift);
712 ShiftedB = Builder.CreateLShr(
B, MaskedShift);
715 Value *Result = Builder.CreateOr(ShiftedA, ShiftedB);
723 Type *Ty =
X->getType();
726 if (IntrinsicId == Intrinsic::powi)
727 Y = Builder.CreateSIToFP(
Y, Ty);
730 Builder.CreateIntrinsic(Ty, Intrinsic::log2, {
X},
nullptr,
"elt.log2");
731 auto *
Mul = Builder.CreateFMul(Log2Call,
Y);
733 Builder.CreateIntrinsic(Ty, Intrinsic::exp2, {
Mul},
nullptr,
"elt.exp2");
743 Type *Ty =
X->getType();
746 Constant *One = ConstantFP::get(Ty->getScalarType(), 1.0);
747 Constant *Zero = ConstantFP::get(Ty->getScalarType(), 0.0);
750 if (Ty != Ty->getScalarType()) {
758 return Builder.CreateSelect(
Cond, Zero, One);
763 Type *Ty =
X->getType();
766 return Builder.CreateFMul(
X, PiOver180);
776 "Only expand double or int64 scalars or vectors");
777 bool IsVector =
false;
778 unsigned ExtractNum = 2;
780 ExtractNum = 2 * VT->getNumElements();
782 assert(IsRaw || ExtractNum == 4 &&
"TypedBufferLoad vector must be size 2");
791 while (ExtractNum > 0) {
792 unsigned LoadNum = std::min(ExtractNum, 4u);
796 Intrinsic::ID LoadIntrinsic = Intrinsic::dx_resource_load_typedbuffer;
799 LoadIntrinsic = Intrinsic::dx_resource_load_rawbuffer;
800 Value *Tmp = Builder.getInt32(4 *
Base * 2);
801 Args.push_back(Builder.CreateAdd(Orig->
getOperand(2), Tmp));
804 CallInst *Load = Builder.CreateIntrinsic(LoadType, LoadIntrinsic, Args);
808 Value *Extract = Builder.CreateExtractValue(Load, {0});
811 for (
unsigned I = 0;
I < LoadNum; ++
I)
813 Builder.CreateExtractElement(Extract, Builder.getInt32(
I)));
816 for (
unsigned I = 0;
I < LoadNum;
I += 2) {
817 Value *Combined =
nullptr;
820 Combined = Builder.CreateIntrinsic(
821 Builder.getDoubleTy(), Intrinsic::dx_asdouble,
822 {ExtractElements[I], ExtractElements[I + 1]});
827 Builder.CreateZExt(ExtractElements[
I], Builder.getInt64Ty());
829 Builder.CreateZExt(ExtractElements[
I + 1], Builder.getInt64Ty());
831 Value *ShiftedHi = Builder.CreateShl(
Hi, Builder.getInt64(32));
833 Combined = Builder.CreateOr(
Lo, ShiftedHi);
837 Result = Builder.CreateInsertElement(Result, Combined,
838 Builder.getInt32((
I / 2) +
Base));
843 ExtractNum -= LoadNum;
847 Value *CheckBit =
nullptr;
858 if (Indices[0] == 0) {
860 EVI->replaceAllUsesWith(Result);
863 assert(Indices[0] == 1 &&
"Unexpected type for typedbufferload");
868 for (
Value *L : Loads)
869 CheckBits.
push_back(Builder.CreateExtractValue(L, {1}));
870 CheckBit = Builder.CreateAnd(CheckBits);
872 EVI->replaceAllUsesWith(CheckBit);
874 EVI->eraseFromParent();
883 unsigned ValIndex = IsRaw ? 3 : 2;
888 "Only expand double or int64 scalars or vectors");
891 bool IsVector =
false;
892 unsigned ExtractNum = 2;
895 VecLen = VT->getNumElements();
896 assert(IsRaw || VecLen == 2 &&
"TypedBufferStore vector must be size 2");
897 ExtractNum = VecLen * 2;
910 Value *LowBits =
nullptr;
911 Value *HighBits =
nullptr;
915 Value *Split = Builder.CreateIntrinsic(SplitTy, Intrinsic::dx_splitdouble,
917 LowBits = Builder.CreateExtractValue(Split, 0);
918 HighBits = Builder.CreateExtractValue(Split, 1);
922 Constant *ShiftAmt = Builder.getInt64(32);
928 LowBits = Builder.CreateTrunc(InputVal, SplitElementTy);
929 Value *ShiftedVal = Builder.CreateLShr(InputVal, ShiftAmt);
930 HighBits = Builder.CreateTrunc(ShiftedVal, SplitElementTy);
935 for (
unsigned I = 0;
I < VecLen; ++
I) {
937 Mask.push_back(
I + VecLen);
939 Val = Builder.CreateShuffleVector(LowBits, HighBits, Mask);
941 Val = Builder.CreateInsertElement(Val, LowBits, Builder.getInt32(0));
942 Val = Builder.CreateInsertElement(Val, HighBits, Builder.getInt32(1));
949 while (ExtractNum > 0) {
950 unsigned StoreNum = std::min(ExtractNum, 4u);
952 Intrinsic::ID StoreIntrinsic = Intrinsic::dx_resource_store_typedbuffer;
955 StoreIntrinsic = Intrinsic::dx_resource_store_rawbuffer;
957 Args.push_back(Builder.CreateAdd(Orig->
getOperand(2), Tmp));
961 for (
unsigned I = 0;
I < StoreNum; ++
I) {
962 Mask.push_back(
Base +
I);
967 SubVal = Builder.CreateShuffleVector(Val, Mask);
969 Args.push_back(SubVal);
971 Builder.CreateIntrinsic(Builder.getVoidTy(), StoreIntrinsic, Args);
973 ExtractNum -= StoreNum;
981 if (ClampIntrinsic == Intrinsic::dx_uclamp)
982 return Intrinsic::umax;
983 if (ClampIntrinsic == Intrinsic::dx_sclamp)
984 return Intrinsic::smax;
985 assert(ClampIntrinsic == Intrinsic::dx_nclamp);
986 return Intrinsic::maxnum;
990 if (ClampIntrinsic == Intrinsic::dx_uclamp)
991 return Intrinsic::umin;
992 if (ClampIntrinsic == Intrinsic::dx_sclamp)
993 return Intrinsic::smin;
994 assert(ClampIntrinsic == Intrinsic::dx_nclamp);
995 return Intrinsic::minnum;
1003 Type *Ty =
X->getType();
1005 auto *MaxCall = Builder.CreateIntrinsic(Ty,
getMaxForClamp(ClampIntrinsic),
1006 {
X, Min},
nullptr,
"dx.max");
1007 return Builder.CreateIntrinsic(Ty,
getMinForClamp(ClampIntrinsic),
1008 {MaxCall, Max},
nullptr,
"dx.min");
1013 Type *Ty =
X->getType();
1016 return Builder.CreateFMul(
X, DegreesRatio);
1021 Type *Ty =
X->getType();
1031 GT = Builder.CreateFCmpOLT(Zero,
X);
1032 LT = Builder.CreateFCmpOLT(
X, Zero);
1035 GT = Builder.CreateICmpSLT(Zero,
X);
1036 LT = Builder.CreateICmpSLT(
X, Zero);
1039 Value *ZextGT = Builder.CreateZExt(GT, RetTy);
1040 Value *ZextLT = Builder.CreateZExt(LT, RetTy);
1042 return Builder.CreateSub(ZextGT, ZextLT);
1046 Value *Result =
nullptr;
1048 switch (IntrinsicId) {
1049 case Intrinsic::abs:
1052 case Intrinsic::assume:
1055 case Intrinsic::atan2:
1058 case Intrinsic::fshl:
1061 case Intrinsic::fshr:
1064 case Intrinsic::exp:
1067 case Intrinsic::is_fpclass:
1070 case Intrinsic::log:
1073 case Intrinsic::log10:
1076 case Intrinsic::pow:
1077 case Intrinsic::powi:
1080 case Intrinsic::dx_all:
1081 case Intrinsic::dx_any:
1084 case Intrinsic::dx_cross:
1087 case Intrinsic::dx_uclamp:
1088 case Intrinsic::dx_sclamp:
1089 case Intrinsic::dx_nclamp:
1092 case Intrinsic::dx_degrees:
1095 case Intrinsic::dx_isinf:
1098 case Intrinsic::dx_isnan:
1101 case Intrinsic::dx_lerp:
1104 case Intrinsic::dx_normalize:
1107 case Intrinsic::dx_fdot:
1110 case Intrinsic::dx_sdot:
1111 case Intrinsic::dx_udot:
1114 case Intrinsic::dx_sign:
1117 case Intrinsic::dx_step:
1120 case Intrinsic::dx_radians:
1123 case Intrinsic::dx_resource_load_rawbuffer:
1127 case Intrinsic::dx_resource_store_rawbuffer:
1131 case Intrinsic::dx_resource_load_typedbuffer:
1135 case Intrinsic::dx_resource_store_typedbuffer:
1139 case Intrinsic::usub_sat:
1142 case Intrinsic::vector_reduce_add:
1143 case Intrinsic::vector_reduce_fadd:
1159 bool IntrinsicExpanded =
false;
1166 if (
F.user_empty() && IntrinsicExpanded)
1167 F.eraseFromParent();
1186 "DXIL Intrinsic Expansion",
false,
false)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static Value * expand16BitIsNormal(CallInst *Orig)
static Value * expandNormalizeIntrinsic(CallInst *Orig)
static bool expandIntrinsic(Function &F, CallInst *Orig)
static Value * expandClampIntrinsic(CallInst *Orig, Intrinsic::ID ClampIntrinsic)
static Value * expand16BitIsInf(CallInst *Orig)
static bool expansionIntrinsics(Module &M)
static Value * expand16BitIsFinite(CallInst *Orig)
static Value * expandLerpIntrinsic(CallInst *Orig)
static Value * expandCrossIntrinsic(CallInst *Orig)
static Value * expandUsubSat(CallInst *Orig)
static Value * expandAnyOrAllIntrinsic(CallInst *Orig, Intrinsic::ID IntrinsicId)
static Value * expandVecReduceAdd(CallInst *Orig, Intrinsic::ID IntrinsicId)
static Value * expandAtan2Intrinsic(CallInst *Orig)
static Value * expandLog10Intrinsic(CallInst *Orig)
static Intrinsic::ID getMinForClamp(Intrinsic::ID ClampIntrinsic)
static Value * expandStepIntrinsic(CallInst *Orig)
static Value * expandIntegerDotIntrinsic(CallInst *Orig, Intrinsic::ID DotIntrinsic)
static bool expandBufferStoreIntrinsic(CallInst *Orig, bool IsRaw)
static Value * expandLogIntrinsic(CallInst *Orig, float LogConstVal=numbers::ln2f)
static Value * expandDegreesIntrinsic(CallInst *Orig)
static Value * expandPowIntrinsic(CallInst *Orig, Intrinsic::ID IntrinsicId)
static bool resourceAccessNeeds64BitExpansion(Module *M, Type *OverloadTy, bool IsRaw)
static Value * expandExpIntrinsic(CallInst *Orig)
static Value * expand16BitIsNaN(CallInst *Orig)
static Value * expandSignIntrinsic(CallInst *Orig)
static Intrinsic::ID getMaxForClamp(Intrinsic::ID ClampIntrinsic)
static Value * expandAbs(CallInst *Orig)
static Value * expandFloatDotIntrinsic(CallInst *Orig, Value *A, Value *B)
static Value * expandRadiansIntrinsic(CallInst *Orig)
static bool isIntrinsicExpansion(Function &F)
static bool expandBufferLoadIntrinsic(CallInst *Orig, bool IsRaw)
static Value * expandIsFPClass(CallInst *Orig)
static Value * expandFunnelShiftIntrinsic(CallInst *Orig)
Module.h This file contains the declarations for the Module class.
This header defines various interfaces for pass management in LLVM.
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
const SmallVectorImpl< MachineOperand > & Cond
static unsigned getNumElements(Type *Ty)
This file defines the SmallVector class.
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
static TableGen::Emitter::OptClass< SkeletonEmitter > X("gen-skeleton-class", "Generate example skeleton class")
bool runOnModule(Module &M) override
runOnModule - Virtual method overriden by subclasses to process the module being operated on.
DXILIntrinsicExpansionLegacy()
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
void setAttributes(AttributeList A)
Set the attributes for this call.
Value * getArgOperand(unsigned i) const
FunctionType * getFunctionType() const
AttributeList getAttributes() const
Return the attributes for this call.
This class represents a function call, abstracting a target machine's calling convention.
void setTailCall(bool IsTc=true)
static LLVM_ABI Constant * getSplat(ElementCount EC, Constant *Elt)
Return a ConstantVector with the specified constant in each element.
This is an important base class in LLVM.
static LLVM_ABI Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
LLVM_ABI bool isZeroValue() const
Return true if the value is negative zero or null value.
PreservedAnalyses run(Module &M, ModuleAnalysisManager &)
static constexpr ElementCount getFixed(ScalarTy MinVal)
static LLVM_ABI FixedVectorType * get(Type *ElementType, unsigned NumElts)
Type * getParamType(unsigned i) const
Parameter type accessors.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
LLVM_ABI const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
LLVM_ABI InstListType::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
LLVM_ABI FastMathFlags getFastMathFlags() const LLVM_READONLY
Convenience function for getting all the fast-math flags, which must be an operator which supports th...
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
A Module instance is used to store all the information related to an LLVM module.
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
static LLVM_ABI StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)
This static method is the primary way to create a literal StructType.
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM_ABI Type * getStructElementType(unsigned N) const
bool isVectorTy() const
True if this is an instance of VectorType.
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
LLVM_ABI TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
static LLVM_ABI IntegerType * getInt16Ty(LLVMContext &C)
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
bool isFloatingPointTy() const
Return true if this is one of the floating-point types.
bool isIntegerTy() const
True if this is an instance of IntegerType.
static LLVM_ABI IntegerType * getIntNTy(LLVMContext &C, unsigned N)
Value * getOperand(unsigned i) const
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
LLVM_ABI void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
iterator_range< user_iterator > users()
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
static LLVM_ABI VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
Represents a version number in the form major[.minor[.subminor[.build]]].
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
FunctionAddr VTableAddr uintptr_t uintptr_t Int32Ty
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
ModulePass * createDXILIntrinsicExpansionLegacyPass()
Pass to expand intrinsic operations that lack DXIL opCodes.
@ Sub
Subtraction of integers.
constexpr unsigned BitWidth
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
LLVM_ABI void reportFatalUsageError(Error Err)
Report a fatal error that does not indicate a bug in LLVM.