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()) {
493 Value *NegZeroSplat = Builder.CreateVectorSplat(FNumElem, NegZero);
495 Builder.CreateICmpEQ(FBitCast, NegZeroSplat,
"is.fpclass.negzero");
497 RetVal = Builder.CreateICmpEQ(FBitCast, NegZero,
"is.fpclass.negzero");
509 Type *Ty =
X->getType();
514 if (IntrinsicId == Intrinsic::dx_any)
515 return Builder.CreateOr(Result, Elt);
516 assert(IntrinsicId == Intrinsic::dx_all);
517 return Builder.CreateAnd(Result, Elt);
520 Value *Result =
nullptr;
521 if (!Ty->isVectorTy()) {
523 ? Builder.CreateFCmpUNE(
X, ConstantFP::get(EltTy, 0))
524 : Builder.CreateICmpNE(
X, ConstantInt::get(EltTy, 0));
529 ? Builder.CreateFCmpUNE(
532 ConstantFP::get(EltTy, 0)))
533 : Builder.CreateICmpNE(
536 ConstantInt::get(EltTy, 0)));
537 Result = Builder.CreateExtractElement(
Cond, (
uint64_t)0);
538 for (
unsigned I = 1;
I < XVec->getNumElements();
I++) {
539 Value *Elt = Builder.CreateExtractElement(
Cond,
I);
540 Result = ApplyOp(IntrinsicId, Result, Elt);
551 auto *V = Builder.CreateFSub(
Y,
X);
552 V = Builder.CreateFMul(S, V);
553 return Builder.CreateFAdd(
X, V,
"dx.lerp");
560 Type *Ty =
X->getType();
566 ConstantFP::get(EltTy, LogConstVal))
567 : ConstantFP::get(EltTy, LogConstVal);
569 Builder.CreateIntrinsic(Ty, Intrinsic::log2, {
X},
nullptr,
"elt.log2");
572 return Builder.CreateFMul(Ln2Const, Log2Call);
589 const APFloat &fpVal = constantFP->getValueAPF();
593 return Builder.CreateFDiv(
X,
X);
601 const APFloat &fpVal = constantFP->getValueAPF();
606 Value *Multiplicand = Builder.CreateIntrinsic(EltTy, Intrinsic::dx_rsqrt,
608 nullptr,
"dx.rsqrt");
610 Value *MultiplicandVec =
611 Builder.CreateVectorSplat(XVec->getNumElements(), Multiplicand);
612 return Builder.CreateFMul(
X, MultiplicandVec);
618 Type *Ty =
X->getType();
622 Value *Tan = Builder.CreateFDiv(
Y,
X);
625 Builder.CreateIntrinsic(Ty, Intrinsic::atan, {Tan},
nullptr,
"Elt.Atan");
633 Constant *Zero = ConstantFP::get(Ty, 0);
634 Value *AtanAddPi = Builder.CreateFAdd(Atan, Pi);
635 Value *AtanSubPi = Builder.CreateFSub(Atan, Pi);
638 Value *Result = Atan;
639 Value *XLt0 = Builder.CreateFCmpOLT(
X, Zero);
640 Value *XEq0 = Builder.CreateFCmpOEQ(
X, Zero);
641 Value *YGe0 = Builder.CreateFCmpOGE(
Y, Zero);
642 Value *YLt0 = Builder.CreateFCmpOLT(
Y, Zero);
645 Value *XLt0AndYGe0 = Builder.CreateAnd(XLt0, YGe0);
646 Result = Builder.CreateSelect(XLt0AndYGe0, AtanAddPi, Result);
649 Value *XLt0AndYLt0 = Builder.CreateAnd(XLt0, YLt0);
650 Result = Builder.CreateSelect(XLt0AndYLt0, AtanSubPi, Result);
653 Value *XEq0AndYLt0 = Builder.CreateAnd(XEq0, YLt0);
654 Result = Builder.CreateSelect(XEq0AndYLt0, NegHalfPi, Result);
657 Value *XEq0AndYGe0 = Builder.CreateAnd(XEq0, YGe0);
658 Result = Builder.CreateSelect(XEq0AndYGe0, HalfPi, Result);
663template <
bool LeftFunnel>
672 unsigned BitWidth = Ty->getScalarSizeInBits();
674 "Can't use Mask to compute modulo and inverse");
689 Constant *Mask = ConstantInt::get(Ty, Ty->getScalarSizeInBits() - 1);
694 Value *MaskedShift = Builder.CreateAnd(Shift, Mask);
699 Value *NotShift = Builder.CreateNot(Shift);
700 Value *InverseShift = Builder.CreateAnd(NotShift, Mask);
702 Constant *One = ConstantInt::get(Ty, 1);
707 ShiftedA = Builder.CreateShl(
A, MaskedShift);
708 Value *ShiftB1 = Builder.CreateLShr(
B, One);
709 ShiftedB = Builder.CreateLShr(ShiftB1, InverseShift);
711 Value *ShiftA1 = Builder.CreateShl(
A, One);
712 ShiftedA = Builder.CreateShl(ShiftA1, InverseShift);
713 ShiftedB = Builder.CreateLShr(
B, MaskedShift);
716 Value *Result = Builder.CreateOr(ShiftedA, ShiftedB);
724 Type *Ty =
X->getType();
727 if (IntrinsicId == Intrinsic::powi)
728 Y = Builder.CreateSIToFP(
Y, Ty);
731 Builder.CreateIntrinsic(Ty, Intrinsic::log2, {
X},
nullptr,
"elt.log2");
732 auto *
Mul = Builder.CreateFMul(Log2Call,
Y);
734 Builder.CreateIntrinsic(Ty, Intrinsic::exp2, {
Mul},
nullptr,
"elt.exp2");
744 Type *Ty =
X->getType();
747 Constant *One = ConstantFP::get(Ty->getScalarType(), 1.0);
748 Constant *Zero = ConstantFP::get(Ty->getScalarType(), 0.0);
751 if (Ty != Ty->getScalarType()) {
759 return Builder.CreateSelect(
Cond, Zero, One);
764 Type *Ty =
X->getType();
767 return Builder.CreateFMul(
X, PiOver180);
777 "Only expand double or int64 scalars or vectors");
778 bool IsVector =
false;
779 unsigned ExtractNum = 2;
781 ExtractNum = 2 * VT->getNumElements();
783 assert(IsRaw || ExtractNum == 4 &&
"TypedBufferLoad vector must be size 2");
792 while (ExtractNum > 0) {
793 unsigned LoadNum = std::min(ExtractNum, 4u);
797 Intrinsic::ID LoadIntrinsic = Intrinsic::dx_resource_load_typedbuffer;
800 LoadIntrinsic = Intrinsic::dx_resource_load_rawbuffer;
801 Value *Tmp = Builder.getInt32(4 *
Base * 2);
802 Args.push_back(Builder.CreateAdd(Orig->
getOperand(2), Tmp));
805 CallInst *Load = Builder.CreateIntrinsic(LoadType, LoadIntrinsic, Args);
809 Value *Extract = Builder.CreateExtractValue(Load, {0});
812 for (
unsigned I = 0;
I < LoadNum; ++
I)
814 Builder.CreateExtractElement(Extract, Builder.getInt32(
I)));
817 for (
unsigned I = 0;
I < LoadNum;
I += 2) {
818 Value *Combined =
nullptr;
821 Combined = Builder.CreateIntrinsic(
822 Builder.getDoubleTy(), Intrinsic::dx_asdouble,
823 {ExtractElements[I], ExtractElements[I + 1]});
828 Builder.CreateZExt(ExtractElements[
I], Builder.getInt64Ty());
830 Builder.CreateZExt(ExtractElements[
I + 1], Builder.getInt64Ty());
832 Value *ShiftedHi = Builder.CreateShl(
Hi, Builder.getInt64(32));
834 Combined = Builder.CreateOr(
Lo, ShiftedHi);
838 Result = Builder.CreateInsertElement(Result, Combined,
839 Builder.getInt32((
I / 2) +
Base));
844 ExtractNum -= LoadNum;
848 Value *CheckBit =
nullptr;
859 if (Indices[0] == 0) {
861 EVI->replaceAllUsesWith(Result);
864 assert(Indices[0] == 1 &&
"Unexpected type for typedbufferload");
869 for (
Value *L : Loads)
870 CheckBits.
push_back(Builder.CreateExtractValue(L, {1}));
871 CheckBit = Builder.CreateAnd(CheckBits);
873 EVI->replaceAllUsesWith(CheckBit);
875 EVI->eraseFromParent();
884 unsigned ValIndex = IsRaw ? 3 : 2;
889 "Only expand double or int64 scalars or vectors");
892 bool IsVector =
false;
893 unsigned ExtractNum = 2;
896 VecLen = VT->getNumElements();
897 assert(IsRaw || VecLen == 2 &&
"TypedBufferStore vector must be size 2");
898 ExtractNum = VecLen * 2;
911 Value *LowBits =
nullptr;
912 Value *HighBits =
nullptr;
916 Value *Split = Builder.CreateIntrinsic(SplitTy, Intrinsic::dx_splitdouble,
918 LowBits = Builder.CreateExtractValue(Split, 0);
919 HighBits = Builder.CreateExtractValue(Split, 1);
923 Constant *ShiftAmt = Builder.getInt64(32);
929 LowBits = Builder.CreateTrunc(InputVal, SplitElementTy);
930 Value *ShiftedVal = Builder.CreateLShr(InputVal, ShiftAmt);
931 HighBits = Builder.CreateTrunc(ShiftedVal, SplitElementTy);
936 for (
unsigned I = 0;
I < VecLen; ++
I) {
938 Mask.push_back(
I + VecLen);
940 Val = Builder.CreateShuffleVector(LowBits, HighBits, Mask);
942 Val = Builder.CreateInsertElement(Val, LowBits, Builder.getInt32(0));
943 Val = Builder.CreateInsertElement(Val, HighBits, Builder.getInt32(1));
950 while (ExtractNum > 0) {
951 unsigned StoreNum = std::min(ExtractNum, 4u);
953 Intrinsic::ID StoreIntrinsic = Intrinsic::dx_resource_store_typedbuffer;
956 StoreIntrinsic = Intrinsic::dx_resource_store_rawbuffer;
958 Args.push_back(Builder.CreateAdd(Orig->
getOperand(2), Tmp));
962 for (
unsigned I = 0;
I < StoreNum; ++
I) {
963 Mask.push_back(
Base +
I);
968 SubVal = Builder.CreateShuffleVector(Val, Mask);
970 Args.push_back(SubVal);
972 Builder.CreateIntrinsic(Builder.getVoidTy(), StoreIntrinsic, Args);
974 ExtractNum -= StoreNum;
982 if (ClampIntrinsic == Intrinsic::dx_uclamp)
983 return Intrinsic::umax;
984 if (ClampIntrinsic == Intrinsic::dx_sclamp)
985 return Intrinsic::smax;
986 assert(ClampIntrinsic == Intrinsic::dx_nclamp);
987 return Intrinsic::maxnum;
991 if (ClampIntrinsic == Intrinsic::dx_uclamp)
992 return Intrinsic::umin;
993 if (ClampIntrinsic == Intrinsic::dx_sclamp)
994 return Intrinsic::smin;
995 assert(ClampIntrinsic == Intrinsic::dx_nclamp);
996 return Intrinsic::minnum;
1004 Type *Ty =
X->getType();
1006 auto *MaxCall = Builder.CreateIntrinsic(Ty,
getMaxForClamp(ClampIntrinsic),
1007 {
X, Min},
nullptr,
"dx.max");
1008 return Builder.CreateIntrinsic(Ty,
getMinForClamp(ClampIntrinsic),
1009 {MaxCall, Max},
nullptr,
"dx.min");
1014 Type *Ty =
X->getType();
1017 return Builder.CreateFMul(
X, DegreesRatio);
1022 Type *Ty =
X->getType();
1032 GT = Builder.CreateFCmpOLT(Zero,
X);
1033 LT = Builder.CreateFCmpOLT(
X, Zero);
1036 GT = Builder.CreateICmpSLT(Zero,
X);
1037 LT = Builder.CreateICmpSLT(
X, Zero);
1040 Value *ZextGT = Builder.CreateZExt(GT, RetTy);
1041 Value *ZextLT = Builder.CreateZExt(LT, RetTy);
1043 return Builder.CreateSub(ZextGT, ZextLT);
1047 Value *Result =
nullptr;
1049 switch (IntrinsicId) {
1050 case Intrinsic::abs:
1053 case Intrinsic::assume:
1056 case Intrinsic::atan2:
1059 case Intrinsic::fshl:
1062 case Intrinsic::fshr:
1065 case Intrinsic::exp:
1068 case Intrinsic::is_fpclass:
1071 case Intrinsic::log:
1074 case Intrinsic::log10:
1077 case Intrinsic::pow:
1078 case Intrinsic::powi:
1081 case Intrinsic::dx_all:
1082 case Intrinsic::dx_any:
1085 case Intrinsic::dx_cross:
1088 case Intrinsic::dx_uclamp:
1089 case Intrinsic::dx_sclamp:
1090 case Intrinsic::dx_nclamp:
1093 case Intrinsic::dx_degrees:
1096 case Intrinsic::dx_isinf:
1099 case Intrinsic::dx_isnan:
1102 case Intrinsic::dx_lerp:
1105 case Intrinsic::dx_normalize:
1108 case Intrinsic::dx_fdot:
1111 case Intrinsic::dx_sdot:
1112 case Intrinsic::dx_udot:
1115 case Intrinsic::dx_sign:
1118 case Intrinsic::dx_step:
1121 case Intrinsic::dx_radians:
1124 case Intrinsic::dx_resource_load_rawbuffer:
1128 case Intrinsic::dx_resource_store_rawbuffer:
1132 case Intrinsic::dx_resource_load_typedbuffer:
1136 case Intrinsic::dx_resource_store_typedbuffer:
1140 case Intrinsic::usub_sat:
1143 case Intrinsic::vector_reduce_add:
1144 case Intrinsic::vector_reduce_fadd:
1160 bool IntrinsicExpanded =
false;
1167 if (
F.user_empty() && IntrinsicExpanded)
1168 F.eraseFromParent();
1187 "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.