23#include "llvm/IR/IntrinsicsDirectX.h"
32#define DEBUG_TYPE "dxil-intrinsic-expansion"
47 if (IsRaw && M->getTargetTriple().getDXILVersion() >
VersionTuple(1, 2))
56 if (M->getTargetTriple().getDXILVersion() >=
VersionTuple(1, 9))
61 if (!ValTy->getScalarType()->isHalfTy())
71 ConstantInt::get(IType, 0x7c00))
72 : ConstantInt::get(IType, 0x7c00);
79 ConstantInt::get(IType, 0xfc00))
80 : ConstantInt::get(IType, 0xfc00);
82 Value *IVal = Builder.CreateBitCast(Val, PosInf->
getType());
83 Value *B1 = Builder.CreateICmpEQ(IVal, PosInf);
84 Value *B2 = Builder.CreateICmpEQ(IVal, NegInf);
85 Value *B3 = Builder.CreateOr(B1, B2);
91 if (M->getTargetTriple().getDXILVersion() >=
VersionTuple(1, 9))
96 if (!ValTy->getScalarType()->isHalfTy())
107 ConstantInt::get(IType, 0x7c00))
108 : ConstantInt::get(IType, 0x7c00);
114 ConstantInt::get(IType, 0x3ff))
115 : ConstantInt::get(IType, 0x3ff);
122 ConstantInt::get(IType, 0))
123 : ConstantInt::get(IType, 0);
125 Value *IVal = Builder.CreateBitCast(Val, ExpBitMask->
getType());
126 Value *Exp = Builder.CreateAnd(IVal, ExpBitMask);
127 Value *B1 = Builder.CreateICmpEQ(Exp, ExpBitMask);
129 Value *Sig = Builder.CreateAnd(IVal, SigBitMask);
130 Value *B2 = Builder.CreateICmpNE(Sig, Zero);
131 Value *B3 = Builder.CreateAnd(B1, B2);
137 if (M->getTargetTriple().getDXILVersion() >=
VersionTuple(1, 9))
142 if (!ValTy->getScalarType()->isHalfTy())
153 ConstantInt::get(IType, 0x7c00))
154 : ConstantInt::get(IType, 0x7c00);
156 Value *IVal = Builder.CreateBitCast(Val, ExpBitMask->
getType());
157 Value *Exp = Builder.CreateAnd(IVal, ExpBitMask);
158 Value *B1 = Builder.CreateICmpNE(Exp, ExpBitMask);
164 if (M->getTargetTriple().getDXILVersion() >=
VersionTuple(1, 9))
169 if (!ValTy->getScalarType()->isHalfTy())
180 ConstantInt::get(IType, 0x7c00))
181 : ConstantInt::get(IType, 0x7c00);
187 ConstantInt::get(IType, 0))
188 : ConstantInt::get(IType, 0);
190 Value *IVal = Builder.CreateBitCast(Val, ExpBitMask->
getType());
191 Value *Exp = Builder.CreateAnd(IVal, ExpBitMask);
192 Value *NotAllZeroes = Builder.CreateICmpNE(Exp, Zero);
193 Value *NotAllOnes = Builder.CreateICmpNE(Exp, ExpBitMask);
194 Value *B1 = Builder.CreateAnd(NotAllZeroes, NotAllOnes);
199 switch (
F.getIntrinsicID()) {
201 case Intrinsic::atan2:
203 case Intrinsic::is_fpclass:
205 case Intrinsic::log10:
207 case Intrinsic::powi:
208 case Intrinsic::dx_all:
209 case Intrinsic::dx_any:
210 case Intrinsic::dx_cross:
211 case Intrinsic::dx_uclamp:
212 case Intrinsic::dx_sclamp:
213 case Intrinsic::dx_nclamp:
214 case Intrinsic::dx_degrees:
215 case Intrinsic::dx_isinf:
216 case Intrinsic::dx_lerp:
217 case Intrinsic::dx_normalize:
218 case Intrinsic::dx_fdot:
219 case Intrinsic::dx_sdot:
220 case Intrinsic::dx_udot:
221 case Intrinsic::dx_sign:
222 case Intrinsic::dx_step:
223 case Intrinsic::dx_radians:
224 case Intrinsic::usub_sat:
225 case Intrinsic::vector_reduce_add:
226 case Intrinsic::vector_reduce_fadd:
228 case Intrinsic::dx_resource_load_rawbuffer:
230 F.getParent(),
F.getReturnType()->getStructElementType(0),
232 case Intrinsic::dx_resource_load_typedbuffer:
234 F.getParent(),
F.getReturnType()->getStructElementType(0),
236 case Intrinsic::dx_resource_store_rawbuffer:
238 F.getParent(),
F.getFunctionType()->getParamType(3),
true);
239 case Intrinsic::dx_resource_store_typedbuffer:
241 F.getParent(),
F.getFunctionType()->getParamType(2),
false);
249 Type *Ty =
A->getType();
253 Value *Cmp = Builder.CreateICmpULT(
A,
B,
"usub.cmp");
254 Value *
Sub = Builder.CreateSub(
A,
B,
"usub.sub");
255 Value *Zero = ConstantInt::get(Ty, 0);
256 return Builder.CreateSelect(Cmp, Zero,
Sub,
"usub.sat");
260 assert(IntrinsicId == Intrinsic::vector_reduce_add ||
261 IntrinsicId == Intrinsic::vector_reduce_fadd);
264 bool IsFAdd = (IntrinsicId == Intrinsic::vector_reduce_fadd);
267 Type *Ty =
X->getType();
269 unsigned XVecSize = XVec->getNumElements();
270 Value *Sum = Builder.CreateExtractElement(
X,
static_cast<uint64_t>(0));
276 Sum = Builder.CreateFAdd(Sum, StartValue);
280 for (
unsigned I = 1;
I < XVecSize;
I++) {
281 Value *Elt = Builder.CreateExtractElement(
X,
I);
283 Sum = Builder.CreateFAdd(Sum, Elt);
285 Sum = Builder.CreateAdd(Sum, Elt);
294 Type *Ty =
X->getType();
300 ConstantInt::get(EltTy, 0))
301 : ConstantInt::get(EltTy, 0);
302 auto *V = Builder.CreateSub(Zero,
X);
303 return Builder.CreateIntrinsic(Ty, Intrinsic::smax, {
X, V},
nullptr,
317 Value *op0_x = Builder.CreateExtractElement(op0, (
uint64_t)0,
"x0");
318 Value *op0_y = Builder.CreateExtractElement(op0, 1,
"x1");
319 Value *op0_z = Builder.CreateExtractElement(op0, 2,
"x2");
321 Value *op1_x = Builder.CreateExtractElement(op1, (
uint64_t)0,
"y0");
322 Value *op1_y = Builder.CreateExtractElement(op1, 1,
"y1");
323 Value *op1_z = Builder.CreateExtractElement(op1, 2,
"y2");
326 Value *xy = Builder.CreateFMul(x0, y1);
327 Value *yx = Builder.CreateFMul(y0, x1);
328 return Builder.CreateFSub(xy, yx, Orig->
getName());
331 Value *yz_zy = MulSub(op0_y, op0_z, op1_y, op1_z);
332 Value *zx_xz = MulSub(op0_z, op0_x, op1_z, op1_x);
333 Value *xy_yx = MulSub(op0_x, op0_y, op1_x, op1_y);
336 cross = Builder.CreateInsertElement(cross, yz_zy, (
uint64_t)0);
337 cross = Builder.CreateInsertElement(cross, zx_xz, 1);
338 cross = Builder.CreateInsertElement(cross, xy_yx, 2);
346 Type *ATy =
A->getType();
347 [[maybe_unused]]
Type *BTy =
B->getType();
357 int NumElts = AVec->getNumElements();
360 DotIntrinsic = Intrinsic::dx_dot2;
363 DotIntrinsic = Intrinsic::dx_dot3;
366 DotIntrinsic = Intrinsic::dx_dot4;
370 "Invalid dot product input vector: length is outside 2-4");
375 for (
int I = 0;
I < NumElts; ++
I)
376 Args.push_back(Builder.CreateExtractElement(
A, Builder.getInt32(
I)));
377 for (
int I = 0;
I < NumElts; ++
I)
378 Args.push_back(Builder.CreateExtractElement(
B, Builder.getInt32(
I)));
379 return Builder.CreateIntrinsic(ATy->
getScalarType(), DotIntrinsic, Args,
394 assert(DotIntrinsic == Intrinsic::dx_sdot ||
395 DotIntrinsic == Intrinsic::dx_udot);
398 Type *ATy =
A->getType();
399 [[maybe_unused]]
Type *BTy =
B->getType();
409 Intrinsic::ID MadIntrinsic = DotIntrinsic == Intrinsic::dx_sdot
411 : Intrinsic::dx_umad;
414 Result = Builder.CreateMul(Elt0, Elt1);
415 for (
unsigned I = 1;
I < AVec->getNumElements();
I++) {
416 Elt0 = Builder.CreateExtractElement(
A,
I);
417 Elt1 = Builder.CreateExtractElement(
B,
I);
418 Result = Builder.CreateIntrinsic(Result->getType(), MadIntrinsic,
428 Type *Ty =
X->getType();
436 Value *NewX = Builder.CreateFMul(Log2eConst,
X);
438 Builder.CreateIntrinsic(Ty, Intrinsic::exp2, {NewX},
nullptr,
"dx.exp2");
450 switch (TCI->getZExtValue()) {
464 Type *FTy =
F->getType();
465 unsigned FNumElem = 0;
471 Type *ElemTy = FVecTy->getElementType();
472 FNumElem = FVecTy->getNumElements();
473 BitWidth = ElemTy->getPrimitiveSizeInBits();
480 Value *FBitCast = Builder.CreateBitCast(
F, BitCastTy);
481 switch (TCI->getZExtValue()) {
487 Value *NegZeroSplat = Builder.CreateVectorSplat(FNumElem, NegZero);
489 Builder.CreateICmpEQ(FBitCast, NegZeroSplat,
"is.fpclass.negzero");
491 RetVal = Builder.CreateICmpEQ(FBitCast, NegZero,
"is.fpclass.negzero");
503 Type *Ty =
X->getType();
508 if (IntrinsicId == Intrinsic::dx_any)
509 return Builder.CreateOr(Result, Elt);
510 assert(IntrinsicId == Intrinsic::dx_all);
511 return Builder.CreateAnd(Result, Elt);
514 Value *Result =
nullptr;
515 if (!Ty->isVectorTy()) {
517 ? Builder.CreateFCmpUNE(
X, ConstantFP::get(EltTy, 0))
518 : Builder.CreateICmpNE(
X, ConstantInt::get(EltTy, 0));
523 ? Builder.CreateFCmpUNE(
526 ConstantFP::get(EltTy, 0)))
527 : Builder.CreateICmpNE(
530 ConstantInt::get(EltTy, 0)));
531 Result = Builder.CreateExtractElement(
Cond, (
uint64_t)0);
532 for (
unsigned I = 1;
I < XVec->getNumElements();
I++) {
533 Value *Elt = Builder.CreateExtractElement(
Cond,
I);
534 Result = ApplyOp(IntrinsicId, Result, Elt);
545 auto *V = Builder.CreateFSub(
Y,
X);
546 V = Builder.CreateFMul(S, V);
547 return Builder.CreateFAdd(
X, V,
"dx.lerp");
554 Type *Ty =
X->getType();
560 ConstantFP::get(EltTy, LogConstVal))
561 : ConstantFP::get(EltTy, LogConstVal);
563 Builder.CreateIntrinsic(Ty, Intrinsic::log2, {
X},
nullptr,
"elt.log2");
566 return Builder.CreateFMul(Ln2Const, Log2Call);
583 const APFloat &fpVal = constantFP->getValueAPF();
587 return Builder.CreateFDiv(
X,
X);
595 const APFloat &fpVal = constantFP->getValueAPF();
600 Value *Multiplicand = Builder.CreateIntrinsic(EltTy, Intrinsic::dx_rsqrt,
602 nullptr,
"dx.rsqrt");
604 Value *MultiplicandVec =
605 Builder.CreateVectorSplat(XVec->getNumElements(), Multiplicand);
606 return Builder.CreateFMul(
X, MultiplicandVec);
612 Type *Ty =
X->getType();
616 Value *Tan = Builder.CreateFDiv(
Y,
X);
619 Builder.CreateIntrinsic(Ty, Intrinsic::atan, {Tan},
nullptr,
"Elt.Atan");
627 Constant *Zero = ConstantFP::get(Ty, 0);
628 Value *AtanAddPi = Builder.CreateFAdd(Atan, Pi);
629 Value *AtanSubPi = Builder.CreateFSub(Atan, Pi);
632 Value *Result = Atan;
633 Value *XLt0 = Builder.CreateFCmpOLT(
X, Zero);
634 Value *XEq0 = Builder.CreateFCmpOEQ(
X, Zero);
635 Value *YGe0 = Builder.CreateFCmpOGE(
Y, Zero);
636 Value *YLt0 = Builder.CreateFCmpOLT(
Y, Zero);
639 Value *XLt0AndYGe0 = Builder.CreateAnd(XLt0, YGe0);
640 Result = Builder.CreateSelect(XLt0AndYGe0, AtanAddPi, Result);
643 Value *XLt0AndYLt0 = Builder.CreateAnd(XLt0, YLt0);
644 Result = Builder.CreateSelect(XLt0AndYLt0, AtanSubPi, Result);
647 Value *XEq0AndYLt0 = Builder.CreateAnd(XEq0, YLt0);
648 Result = Builder.CreateSelect(XEq0AndYLt0, NegHalfPi, Result);
651 Value *XEq0AndYGe0 = Builder.CreateAnd(XEq0, YGe0);
652 Result = Builder.CreateSelect(XEq0AndYGe0, HalfPi, Result);
661 Type *Ty =
X->getType();
664 if (IntrinsicId == Intrinsic::powi)
665 Y = Builder.CreateSIToFP(
Y, Ty);
668 Builder.CreateIntrinsic(Ty, Intrinsic::log2, {
X},
nullptr,
"elt.log2");
669 auto *
Mul = Builder.CreateFMul(Log2Call,
Y);
671 Builder.CreateIntrinsic(Ty, Intrinsic::exp2, {
Mul},
nullptr,
"elt.exp2");
681 Type *Ty =
X->getType();
684 Constant *One = ConstantFP::get(Ty->getScalarType(), 1.0);
685 Constant *Zero = ConstantFP::get(Ty->getScalarType(), 0.0);
688 if (Ty != Ty->getScalarType()) {
696 return Builder.CreateSelect(
Cond, Zero, One);
701 Type *Ty =
X->getType();
704 return Builder.CreateFMul(
X, PiOver180);
714 "Only expand double or int64 scalars or vectors");
715 bool IsVector =
false;
716 unsigned ExtractNum = 2;
718 ExtractNum = 2 * VT->getNumElements();
720 assert(IsRaw || ExtractNum == 4 &&
"TypedBufferLoad vector must be size 2");
729 while (ExtractNum > 0) {
730 unsigned LoadNum = std::min(ExtractNum, 4u);
734 Intrinsic::ID LoadIntrinsic = Intrinsic::dx_resource_load_typedbuffer;
737 LoadIntrinsic = Intrinsic::dx_resource_load_rawbuffer;
738 Value *Tmp = Builder.getInt32(4 *
Base * 2);
739 Args.push_back(Builder.CreateAdd(Orig->
getOperand(2), Tmp));
742 CallInst *Load = Builder.CreateIntrinsic(LoadType, LoadIntrinsic, Args);
746 Value *Extract = Builder.CreateExtractValue(Load, {0});
749 for (
unsigned I = 0;
I < LoadNum; ++
I)
751 Builder.CreateExtractElement(Extract, Builder.getInt32(
I)));
754 for (
unsigned I = 0;
I < LoadNum;
I += 2) {
755 Value *Combined =
nullptr;
758 Combined = Builder.CreateIntrinsic(
759 Builder.getDoubleTy(), Intrinsic::dx_asdouble,
760 {ExtractElements[I], ExtractElements[I + 1]});
765 Builder.CreateZExt(ExtractElements[
I], Builder.getInt64Ty());
767 Builder.CreateZExt(ExtractElements[
I + 1], Builder.getInt64Ty());
769 Value *ShiftedHi = Builder.CreateShl(
Hi, Builder.getInt64(32));
771 Combined = Builder.CreateOr(
Lo, ShiftedHi);
775 Result = Builder.CreateInsertElement(Result, Combined,
776 Builder.getInt32((
I / 2) +
Base));
781 ExtractNum -= LoadNum;
785 Value *CheckBit =
nullptr;
796 if (Indices[0] == 0) {
798 EVI->replaceAllUsesWith(Result);
801 assert(Indices[0] == 1 &&
"Unexpected type for typedbufferload");
806 for (
Value *L : Loads)
807 CheckBits.
push_back(Builder.CreateExtractValue(L, {1}));
808 CheckBit = Builder.CreateAnd(CheckBits);
810 EVI->replaceAllUsesWith(CheckBit);
812 EVI->eraseFromParent();
821 unsigned ValIndex = IsRaw ? 3 : 2;
826 "Only expand double or int64 scalars or vectors");
829 bool IsVector =
false;
830 unsigned ExtractNum = 2;
833 VecLen = VT->getNumElements();
834 assert(IsRaw || VecLen == 2 &&
"TypedBufferStore vector must be size 2");
835 ExtractNum = VecLen * 2;
848 Value *LowBits =
nullptr;
849 Value *HighBits =
nullptr;
853 Value *Split = Builder.CreateIntrinsic(SplitTy, Intrinsic::dx_splitdouble,
855 LowBits = Builder.CreateExtractValue(Split, 0);
856 HighBits = Builder.CreateExtractValue(Split, 1);
860 Constant *ShiftAmt = Builder.getInt64(32);
866 LowBits = Builder.CreateTrunc(InputVal, SplitElementTy);
867 Value *ShiftedVal = Builder.CreateLShr(InputVal, ShiftAmt);
868 HighBits = Builder.CreateTrunc(ShiftedVal, SplitElementTy);
873 for (
unsigned I = 0;
I < VecLen; ++
I) {
875 Mask.push_back(
I + VecLen);
877 Val = Builder.CreateShuffleVector(LowBits, HighBits, Mask);
879 Val = Builder.CreateInsertElement(Val, LowBits, Builder.getInt32(0));
880 Val = Builder.CreateInsertElement(Val, HighBits, Builder.getInt32(1));
887 while (ExtractNum > 0) {
888 unsigned StoreNum = std::min(ExtractNum, 4u);
890 Intrinsic::ID StoreIntrinsic = Intrinsic::dx_resource_store_typedbuffer;
893 StoreIntrinsic = Intrinsic::dx_resource_store_rawbuffer;
895 Args.push_back(Builder.CreateAdd(Orig->
getOperand(2), Tmp));
899 for (
unsigned I = 0;
I < StoreNum; ++
I) {
900 Mask.push_back(
Base +
I);
905 SubVal = Builder.CreateShuffleVector(Val, Mask);
907 Args.push_back(SubVal);
909 Builder.CreateIntrinsic(Builder.getVoidTy(), StoreIntrinsic, Args);
911 ExtractNum -= StoreNum;
919 if (ClampIntrinsic == Intrinsic::dx_uclamp)
920 return Intrinsic::umax;
921 if (ClampIntrinsic == Intrinsic::dx_sclamp)
922 return Intrinsic::smax;
923 assert(ClampIntrinsic == Intrinsic::dx_nclamp);
924 return Intrinsic::maxnum;
928 if (ClampIntrinsic == Intrinsic::dx_uclamp)
929 return Intrinsic::umin;
930 if (ClampIntrinsic == Intrinsic::dx_sclamp)
931 return Intrinsic::smin;
932 assert(ClampIntrinsic == Intrinsic::dx_nclamp);
933 return Intrinsic::minnum;
941 Type *Ty =
X->getType();
943 auto *MaxCall = Builder.CreateIntrinsic(Ty,
getMaxForClamp(ClampIntrinsic),
944 {
X, Min},
nullptr,
"dx.max");
945 return Builder.CreateIntrinsic(Ty,
getMinForClamp(ClampIntrinsic),
946 {MaxCall, Max},
nullptr,
"dx.min");
951 Type *Ty =
X->getType();
954 return Builder.CreateFMul(
X, DegreesRatio);
959 Type *Ty =
X->getType();
969 GT = Builder.CreateFCmpOLT(Zero,
X);
970 LT = Builder.CreateFCmpOLT(
X, Zero);
973 GT = Builder.CreateICmpSLT(Zero,
X);
974 LT = Builder.CreateICmpSLT(
X, Zero);
977 Value *ZextGT = Builder.CreateZExt(GT, RetTy);
978 Value *ZextLT = Builder.CreateZExt(LT, RetTy);
980 return Builder.CreateSub(ZextGT, ZextLT);
984 Value *Result =
nullptr;
986 switch (IntrinsicId) {
990 case Intrinsic::atan2:
996 case Intrinsic::is_fpclass:
1002 case Intrinsic::log10:
1005 case Intrinsic::pow:
1006 case Intrinsic::powi:
1009 case Intrinsic::dx_all:
1010 case Intrinsic::dx_any:
1013 case Intrinsic::dx_cross:
1016 case Intrinsic::dx_uclamp:
1017 case Intrinsic::dx_sclamp:
1018 case Intrinsic::dx_nclamp:
1021 case Intrinsic::dx_degrees:
1024 case Intrinsic::dx_isinf:
1027 case Intrinsic::dx_lerp:
1030 case Intrinsic::dx_normalize:
1033 case Intrinsic::dx_fdot:
1036 case Intrinsic::dx_sdot:
1037 case Intrinsic::dx_udot:
1040 case Intrinsic::dx_sign:
1043 case Intrinsic::dx_step:
1046 case Intrinsic::dx_radians:
1049 case Intrinsic::dx_resource_load_rawbuffer:
1053 case Intrinsic::dx_resource_store_rawbuffer:
1057 case Intrinsic::dx_resource_load_typedbuffer:
1061 case Intrinsic::dx_resource_store_typedbuffer:
1065 case Intrinsic::usub_sat:
1068 case Intrinsic::vector_reduce_add:
1069 case Intrinsic::vector_reduce_fadd:
1085 bool IntrinsicExpanded =
false;
1092 if (
F.user_empty() && IntrinsicExpanded)
1093 F.eraseFromParent();
1112 "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")
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)
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...
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.