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_isnan:
217 case Intrinsic::dx_lerp:
218 case Intrinsic::dx_normalize:
219 case Intrinsic::dx_fdot:
220 case Intrinsic::dx_sdot:
221 case Intrinsic::dx_udot:
222 case Intrinsic::dx_sign:
223 case Intrinsic::dx_step:
224 case Intrinsic::dx_radians:
225 case Intrinsic::usub_sat:
226 case Intrinsic::vector_reduce_add:
227 case Intrinsic::vector_reduce_fadd:
229 case Intrinsic::dx_resource_load_rawbuffer:
231 F.getParent(),
F.getReturnType()->getStructElementType(0),
233 case Intrinsic::dx_resource_load_typedbuffer:
235 F.getParent(),
F.getReturnType()->getStructElementType(0),
237 case Intrinsic::dx_resource_store_rawbuffer:
239 F.getParent(),
F.getFunctionType()->getParamType(3),
true);
240 case Intrinsic::dx_resource_store_typedbuffer:
242 F.getParent(),
F.getFunctionType()->getParamType(2),
false);
250 Type *Ty =
A->getType();
254 Value *Cmp = Builder.CreateICmpULT(
A,
B,
"usub.cmp");
255 Value *
Sub = Builder.CreateSub(
A,
B,
"usub.sub");
256 Value *Zero = ConstantInt::get(Ty, 0);
257 return Builder.CreateSelect(Cmp, Zero,
Sub,
"usub.sat");
261 assert(IntrinsicId == Intrinsic::vector_reduce_add ||
262 IntrinsicId == Intrinsic::vector_reduce_fadd);
265 bool IsFAdd = (IntrinsicId == Intrinsic::vector_reduce_fadd);
268 Type *Ty =
X->getType();
270 unsigned XVecSize = XVec->getNumElements();
271 Value *Sum = Builder.CreateExtractElement(
X,
static_cast<uint64_t>(0));
277 Sum = Builder.CreateFAdd(Sum, StartValue);
281 for (
unsigned I = 1;
I < XVecSize;
I++) {
282 Value *Elt = Builder.CreateExtractElement(
X,
I);
284 Sum = Builder.CreateFAdd(Sum, Elt);
286 Sum = Builder.CreateAdd(Sum, Elt);
295 Type *Ty =
X->getType();
301 ConstantInt::get(EltTy, 0))
302 : ConstantInt::get(EltTy, 0);
303 auto *V = Builder.CreateSub(Zero,
X);
304 return Builder.CreateIntrinsic(Ty, Intrinsic::smax, {
X, V},
nullptr,
318 Value *op0_x = Builder.CreateExtractElement(op0, (
uint64_t)0,
"x0");
319 Value *op0_y = Builder.CreateExtractElement(op0, 1,
"x1");
320 Value *op0_z = Builder.CreateExtractElement(op0, 2,
"x2");
322 Value *op1_x = Builder.CreateExtractElement(op1, (
uint64_t)0,
"y0");
323 Value *op1_y = Builder.CreateExtractElement(op1, 1,
"y1");
324 Value *op1_z = Builder.CreateExtractElement(op1, 2,
"y2");
327 Value *xy = Builder.CreateFMul(x0, y1);
328 Value *yx = Builder.CreateFMul(y0, x1);
329 return Builder.CreateFSub(xy, yx, Orig->
getName());
332 Value *yz_zy = MulSub(op0_y, op0_z, op1_y, op1_z);
333 Value *zx_xz = MulSub(op0_z, op0_x, op1_z, op1_x);
334 Value *xy_yx = MulSub(op0_x, op0_y, op1_x, op1_y);
337 cross = Builder.CreateInsertElement(cross, yz_zy, (
uint64_t)0);
338 cross = Builder.CreateInsertElement(cross, zx_xz, 1);
339 cross = Builder.CreateInsertElement(cross, xy_yx, 2);
347 Type *ATy =
A->getType();
348 [[maybe_unused]]
Type *BTy =
B->getType();
358 int NumElts = AVec->getNumElements();
361 DotIntrinsic = Intrinsic::dx_dot2;
364 DotIntrinsic = Intrinsic::dx_dot3;
367 DotIntrinsic = Intrinsic::dx_dot4;
371 "Invalid dot product input vector: length is outside 2-4");
376 for (
int I = 0;
I < NumElts; ++
I)
377 Args.push_back(Builder.CreateExtractElement(
A, Builder.getInt32(
I)));
378 for (
int I = 0;
I < NumElts; ++
I)
379 Args.push_back(Builder.CreateExtractElement(
B, Builder.getInt32(
I)));
380 return Builder.CreateIntrinsic(ATy->
getScalarType(), DotIntrinsic, Args,
395 assert(DotIntrinsic == Intrinsic::dx_sdot ||
396 DotIntrinsic == Intrinsic::dx_udot);
399 Type *ATy =
A->getType();
400 [[maybe_unused]]
Type *BTy =
B->getType();
410 Intrinsic::ID MadIntrinsic = DotIntrinsic == Intrinsic::dx_sdot
412 : Intrinsic::dx_umad;
415 Result = Builder.CreateMul(Elt0, Elt1);
416 for (
unsigned I = 1;
I < AVec->getNumElements();
I++) {
417 Elt0 = Builder.CreateExtractElement(
A,
I);
418 Elt1 = Builder.CreateExtractElement(
B,
I);
419 Result = Builder.CreateIntrinsic(Result->getType(), MadIntrinsic,
429 Type *Ty =
X->getType();
437 Value *NewX = Builder.CreateFMul(Log2eConst,
X);
439 Builder.CreateIntrinsic(Ty, Intrinsic::exp2, {NewX},
nullptr,
"dx.exp2");
451 switch (TCI->getZExtValue()) {
465 Type *FTy =
F->getType();
466 unsigned FNumElem = 0;
472 Type *ElemTy = FVecTy->getElementType();
473 FNumElem = FVecTy->getNumElements();
474 BitWidth = ElemTy->getPrimitiveSizeInBits();
481 Value *FBitCast = Builder.CreateBitCast(
F, BitCastTy);
482 switch (TCI->getZExtValue()) {
488 Value *NegZeroSplat = Builder.CreateVectorSplat(FNumElem, NegZero);
490 Builder.CreateICmpEQ(FBitCast, NegZeroSplat,
"is.fpclass.negzero");
492 RetVal = Builder.CreateICmpEQ(FBitCast, NegZero,
"is.fpclass.negzero");
504 Type *Ty =
X->getType();
509 if (IntrinsicId == Intrinsic::dx_any)
510 return Builder.CreateOr(Result, Elt);
511 assert(IntrinsicId == Intrinsic::dx_all);
512 return Builder.CreateAnd(Result, Elt);
515 Value *Result =
nullptr;
516 if (!Ty->isVectorTy()) {
518 ? Builder.CreateFCmpUNE(
X, ConstantFP::get(EltTy, 0))
519 : Builder.CreateICmpNE(
X, ConstantInt::get(EltTy, 0));
524 ? Builder.CreateFCmpUNE(
527 ConstantFP::get(EltTy, 0)))
528 : Builder.CreateICmpNE(
531 ConstantInt::get(EltTy, 0)));
532 Result = Builder.CreateExtractElement(
Cond, (
uint64_t)0);
533 for (
unsigned I = 1;
I < XVec->getNumElements();
I++) {
534 Value *Elt = Builder.CreateExtractElement(
Cond,
I);
535 Result = ApplyOp(IntrinsicId, Result, Elt);
546 auto *V = Builder.CreateFSub(
Y,
X);
547 V = Builder.CreateFMul(S, V);
548 return Builder.CreateFAdd(
X, V,
"dx.lerp");
555 Type *Ty =
X->getType();
561 ConstantFP::get(EltTy, LogConstVal))
562 : ConstantFP::get(EltTy, LogConstVal);
564 Builder.CreateIntrinsic(Ty, Intrinsic::log2, {
X},
nullptr,
"elt.log2");
567 return Builder.CreateFMul(Ln2Const, Log2Call);
584 const APFloat &fpVal = constantFP->getValueAPF();
588 return Builder.CreateFDiv(
X,
X);
596 const APFloat &fpVal = constantFP->getValueAPF();
601 Value *Multiplicand = Builder.CreateIntrinsic(EltTy, Intrinsic::dx_rsqrt,
603 nullptr,
"dx.rsqrt");
605 Value *MultiplicandVec =
606 Builder.CreateVectorSplat(XVec->getNumElements(), Multiplicand);
607 return Builder.CreateFMul(
X, MultiplicandVec);
613 Type *Ty =
X->getType();
617 Value *Tan = Builder.CreateFDiv(
Y,
X);
620 Builder.CreateIntrinsic(Ty, Intrinsic::atan, {Tan},
nullptr,
"Elt.Atan");
628 Constant *Zero = ConstantFP::get(Ty, 0);
629 Value *AtanAddPi = Builder.CreateFAdd(Atan, Pi);
630 Value *AtanSubPi = Builder.CreateFSub(Atan, Pi);
633 Value *Result = Atan;
634 Value *XLt0 = Builder.CreateFCmpOLT(
X, Zero);
635 Value *XEq0 = Builder.CreateFCmpOEQ(
X, Zero);
636 Value *YGe0 = Builder.CreateFCmpOGE(
Y, Zero);
637 Value *YLt0 = Builder.CreateFCmpOLT(
Y, Zero);
640 Value *XLt0AndYGe0 = Builder.CreateAnd(XLt0, YGe0);
641 Result = Builder.CreateSelect(XLt0AndYGe0, AtanAddPi, Result);
644 Value *XLt0AndYLt0 = Builder.CreateAnd(XLt0, YLt0);
645 Result = Builder.CreateSelect(XLt0AndYLt0, AtanSubPi, Result);
648 Value *XEq0AndYLt0 = Builder.CreateAnd(XEq0, YLt0);
649 Result = Builder.CreateSelect(XEq0AndYLt0, NegHalfPi, Result);
652 Value *XEq0AndYGe0 = Builder.CreateAnd(XEq0, YGe0);
653 Result = Builder.CreateSelect(XEq0AndYGe0, HalfPi, Result);
662 Type *Ty =
X->getType();
665 if (IntrinsicId == Intrinsic::powi)
666 Y = Builder.CreateSIToFP(
Y, Ty);
669 Builder.CreateIntrinsic(Ty, Intrinsic::log2, {
X},
nullptr,
"elt.log2");
670 auto *
Mul = Builder.CreateFMul(Log2Call,
Y);
672 Builder.CreateIntrinsic(Ty, Intrinsic::exp2, {
Mul},
nullptr,
"elt.exp2");
682 Type *Ty =
X->getType();
685 Constant *One = ConstantFP::get(Ty->getScalarType(), 1.0);
686 Constant *Zero = ConstantFP::get(Ty->getScalarType(), 0.0);
689 if (Ty != Ty->getScalarType()) {
697 return Builder.CreateSelect(
Cond, Zero, One);
702 Type *Ty =
X->getType();
705 return Builder.CreateFMul(
X, PiOver180);
715 "Only expand double or int64 scalars or vectors");
716 bool IsVector =
false;
717 unsigned ExtractNum = 2;
719 ExtractNum = 2 * VT->getNumElements();
721 assert(IsRaw || ExtractNum == 4 &&
"TypedBufferLoad vector must be size 2");
730 while (ExtractNum > 0) {
731 unsigned LoadNum = std::min(ExtractNum, 4u);
735 Intrinsic::ID LoadIntrinsic = Intrinsic::dx_resource_load_typedbuffer;
738 LoadIntrinsic = Intrinsic::dx_resource_load_rawbuffer;
739 Value *Tmp = Builder.getInt32(4 *
Base * 2);
740 Args.push_back(Builder.CreateAdd(Orig->
getOperand(2), Tmp));
743 CallInst *Load = Builder.CreateIntrinsic(LoadType, LoadIntrinsic, Args);
747 Value *Extract = Builder.CreateExtractValue(Load, {0});
750 for (
unsigned I = 0;
I < LoadNum; ++
I)
752 Builder.CreateExtractElement(Extract, Builder.getInt32(
I)));
755 for (
unsigned I = 0;
I < LoadNum;
I += 2) {
756 Value *Combined =
nullptr;
759 Combined = Builder.CreateIntrinsic(
760 Builder.getDoubleTy(), Intrinsic::dx_asdouble,
761 {ExtractElements[I], ExtractElements[I + 1]});
766 Builder.CreateZExt(ExtractElements[
I], Builder.getInt64Ty());
768 Builder.CreateZExt(ExtractElements[
I + 1], Builder.getInt64Ty());
770 Value *ShiftedHi = Builder.CreateShl(
Hi, Builder.getInt64(32));
772 Combined = Builder.CreateOr(
Lo, ShiftedHi);
776 Result = Builder.CreateInsertElement(Result, Combined,
777 Builder.getInt32((
I / 2) +
Base));
782 ExtractNum -= LoadNum;
786 Value *CheckBit =
nullptr;
797 if (Indices[0] == 0) {
799 EVI->replaceAllUsesWith(Result);
802 assert(Indices[0] == 1 &&
"Unexpected type for typedbufferload");
807 for (
Value *L : Loads)
808 CheckBits.
push_back(Builder.CreateExtractValue(L, {1}));
809 CheckBit = Builder.CreateAnd(CheckBits);
811 EVI->replaceAllUsesWith(CheckBit);
813 EVI->eraseFromParent();
822 unsigned ValIndex = IsRaw ? 3 : 2;
827 "Only expand double or int64 scalars or vectors");
830 bool IsVector =
false;
831 unsigned ExtractNum = 2;
834 VecLen = VT->getNumElements();
835 assert(IsRaw || VecLen == 2 &&
"TypedBufferStore vector must be size 2");
836 ExtractNum = VecLen * 2;
849 Value *LowBits =
nullptr;
850 Value *HighBits =
nullptr;
854 Value *Split = Builder.CreateIntrinsic(SplitTy, Intrinsic::dx_splitdouble,
856 LowBits = Builder.CreateExtractValue(Split, 0);
857 HighBits = Builder.CreateExtractValue(Split, 1);
861 Constant *ShiftAmt = Builder.getInt64(32);
867 LowBits = Builder.CreateTrunc(InputVal, SplitElementTy);
868 Value *ShiftedVal = Builder.CreateLShr(InputVal, ShiftAmt);
869 HighBits = Builder.CreateTrunc(ShiftedVal, SplitElementTy);
874 for (
unsigned I = 0;
I < VecLen; ++
I) {
876 Mask.push_back(
I + VecLen);
878 Val = Builder.CreateShuffleVector(LowBits, HighBits, Mask);
880 Val = Builder.CreateInsertElement(Val, LowBits, Builder.getInt32(0));
881 Val = Builder.CreateInsertElement(Val, HighBits, Builder.getInt32(1));
888 while (ExtractNum > 0) {
889 unsigned StoreNum = std::min(ExtractNum, 4u);
891 Intrinsic::ID StoreIntrinsic = Intrinsic::dx_resource_store_typedbuffer;
894 StoreIntrinsic = Intrinsic::dx_resource_store_rawbuffer;
896 Args.push_back(Builder.CreateAdd(Orig->
getOperand(2), Tmp));
900 for (
unsigned I = 0;
I < StoreNum; ++
I) {
901 Mask.push_back(
Base +
I);
906 SubVal = Builder.CreateShuffleVector(Val, Mask);
908 Args.push_back(SubVal);
910 Builder.CreateIntrinsic(Builder.getVoidTy(), StoreIntrinsic, Args);
912 ExtractNum -= StoreNum;
920 if (ClampIntrinsic == Intrinsic::dx_uclamp)
921 return Intrinsic::umax;
922 if (ClampIntrinsic == Intrinsic::dx_sclamp)
923 return Intrinsic::smax;
924 assert(ClampIntrinsic == Intrinsic::dx_nclamp);
925 return Intrinsic::maxnum;
929 if (ClampIntrinsic == Intrinsic::dx_uclamp)
930 return Intrinsic::umin;
931 if (ClampIntrinsic == Intrinsic::dx_sclamp)
932 return Intrinsic::smin;
933 assert(ClampIntrinsic == Intrinsic::dx_nclamp);
934 return Intrinsic::minnum;
942 Type *Ty =
X->getType();
944 auto *MaxCall = Builder.CreateIntrinsic(Ty,
getMaxForClamp(ClampIntrinsic),
945 {
X, Min},
nullptr,
"dx.max");
946 return Builder.CreateIntrinsic(Ty,
getMinForClamp(ClampIntrinsic),
947 {MaxCall, Max},
nullptr,
"dx.min");
952 Type *Ty =
X->getType();
955 return Builder.CreateFMul(
X, DegreesRatio);
960 Type *Ty =
X->getType();
970 GT = Builder.CreateFCmpOLT(Zero,
X);
971 LT = Builder.CreateFCmpOLT(
X, Zero);
974 GT = Builder.CreateICmpSLT(Zero,
X);
975 LT = Builder.CreateICmpSLT(
X, Zero);
978 Value *ZextGT = Builder.CreateZExt(GT, RetTy);
979 Value *ZextLT = Builder.CreateZExt(LT, RetTy);
981 return Builder.CreateSub(ZextGT, ZextLT);
985 Value *Result =
nullptr;
987 switch (IntrinsicId) {
991 case Intrinsic::atan2:
997 case Intrinsic::is_fpclass:
1000 case Intrinsic::log:
1003 case Intrinsic::log10:
1006 case Intrinsic::pow:
1007 case Intrinsic::powi:
1010 case Intrinsic::dx_all:
1011 case Intrinsic::dx_any:
1014 case Intrinsic::dx_cross:
1017 case Intrinsic::dx_uclamp:
1018 case Intrinsic::dx_sclamp:
1019 case Intrinsic::dx_nclamp:
1022 case Intrinsic::dx_degrees:
1025 case Intrinsic::dx_isinf:
1028 case Intrinsic::dx_isnan:
1031 case Intrinsic::dx_lerp:
1034 case Intrinsic::dx_normalize:
1037 case Intrinsic::dx_fdot:
1040 case Intrinsic::dx_sdot:
1041 case Intrinsic::dx_udot:
1044 case Intrinsic::dx_sign:
1047 case Intrinsic::dx_step:
1050 case Intrinsic::dx_radians:
1053 case Intrinsic::dx_resource_load_rawbuffer:
1057 case Intrinsic::dx_resource_store_rawbuffer:
1061 case Intrinsic::dx_resource_load_typedbuffer:
1065 case Intrinsic::dx_resource_store_typedbuffer:
1069 case Intrinsic::usub_sat:
1072 case Intrinsic::vector_reduce_add:
1073 case Intrinsic::vector_reduce_fadd:
1089 bool IntrinsicExpanded =
false;
1096 if (
F.user_empty() && IntrinsicExpanded)
1097 F.eraseFromParent();
1116 "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.