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()) {
200 case Intrinsic::assume:
202 case Intrinsic::atan2:
204 case Intrinsic::is_fpclass:
206 case Intrinsic::log10:
208 case Intrinsic::powi:
209 case Intrinsic::dx_all:
210 case Intrinsic::dx_any:
211 case Intrinsic::dx_cross:
212 case Intrinsic::dx_uclamp:
213 case Intrinsic::dx_sclamp:
214 case Intrinsic::dx_nclamp:
215 case Intrinsic::dx_degrees:
216 case Intrinsic::dx_isinf:
217 case Intrinsic::dx_isnan:
218 case Intrinsic::dx_lerp:
219 case Intrinsic::dx_normalize:
220 case Intrinsic::dx_fdot:
221 case Intrinsic::dx_sdot:
222 case Intrinsic::dx_udot:
223 case Intrinsic::dx_sign:
224 case Intrinsic::dx_step:
225 case Intrinsic::dx_radians:
226 case Intrinsic::usub_sat:
227 case Intrinsic::vector_reduce_add:
228 case Intrinsic::vector_reduce_fadd:
230 case Intrinsic::dx_resource_load_rawbuffer:
232 F.getParent(),
F.getReturnType()->getStructElementType(0),
234 case Intrinsic::dx_resource_load_typedbuffer:
236 F.getParent(),
F.getReturnType()->getStructElementType(0),
238 case Intrinsic::dx_resource_store_rawbuffer:
240 F.getParent(),
F.getFunctionType()->getParamType(3),
true);
241 case Intrinsic::dx_resource_store_typedbuffer:
243 F.getParent(),
F.getFunctionType()->getParamType(2),
false);
251 Type *Ty =
A->getType();
255 Value *Cmp = Builder.CreateICmpULT(
A,
B,
"usub.cmp");
256 Value *
Sub = Builder.CreateSub(
A,
B,
"usub.sub");
257 Value *Zero = ConstantInt::get(Ty, 0);
258 return Builder.CreateSelect(Cmp, Zero,
Sub,
"usub.sat");
262 assert(IntrinsicId == Intrinsic::vector_reduce_add ||
263 IntrinsicId == Intrinsic::vector_reduce_fadd);
266 bool IsFAdd = (IntrinsicId == Intrinsic::vector_reduce_fadd);
269 Type *Ty =
X->getType();
271 unsigned XVecSize = XVec->getNumElements();
272 Value *Sum = Builder.CreateExtractElement(
X,
static_cast<uint64_t>(0));
278 Sum = Builder.CreateFAdd(Sum, StartValue);
282 for (
unsigned I = 1;
I < XVecSize;
I++) {
283 Value *Elt = Builder.CreateExtractElement(
X,
I);
285 Sum = Builder.CreateFAdd(Sum, Elt);
287 Sum = Builder.CreateAdd(Sum, Elt);
296 Type *Ty =
X->getType();
302 ConstantInt::get(EltTy, 0))
303 : ConstantInt::get(EltTy, 0);
304 auto *V = Builder.CreateSub(Zero,
X);
305 return Builder.CreateIntrinsic(Ty, Intrinsic::smax, {
X, V},
nullptr,
319 Value *op0_x = Builder.CreateExtractElement(op0, (
uint64_t)0,
"x0");
320 Value *op0_y = Builder.CreateExtractElement(op0, 1,
"x1");
321 Value *op0_z = Builder.CreateExtractElement(op0, 2,
"x2");
323 Value *op1_x = Builder.CreateExtractElement(op1, (
uint64_t)0,
"y0");
324 Value *op1_y = Builder.CreateExtractElement(op1, 1,
"y1");
325 Value *op1_z = Builder.CreateExtractElement(op1, 2,
"y2");
328 Value *xy = Builder.CreateFMul(x0, y1);
329 Value *yx = Builder.CreateFMul(y0, x1);
330 return Builder.CreateFSub(xy, yx, Orig->
getName());
333 Value *yz_zy = MulSub(op0_y, op0_z, op1_y, op1_z);
334 Value *zx_xz = MulSub(op0_z, op0_x, op1_z, op1_x);
335 Value *xy_yx = MulSub(op0_x, op0_y, op1_x, op1_y);
338 cross = Builder.CreateInsertElement(cross, yz_zy, (
uint64_t)0);
339 cross = Builder.CreateInsertElement(cross, zx_xz, 1);
340 cross = Builder.CreateInsertElement(cross, xy_yx, 2);
348 Type *ATy =
A->getType();
349 [[maybe_unused]]
Type *BTy =
B->getType();
359 int NumElts = AVec->getNumElements();
362 DotIntrinsic = Intrinsic::dx_dot2;
365 DotIntrinsic = Intrinsic::dx_dot3;
368 DotIntrinsic = Intrinsic::dx_dot4;
372 "Invalid dot product input vector: length is outside 2-4");
377 for (
int I = 0;
I < NumElts; ++
I)
378 Args.push_back(Builder.CreateExtractElement(
A, Builder.getInt32(
I)));
379 for (
int I = 0;
I < NumElts; ++
I)
380 Args.push_back(Builder.CreateExtractElement(
B, Builder.getInt32(
I)));
381 return Builder.CreateIntrinsic(ATy->
getScalarType(), DotIntrinsic, Args,
396 assert(DotIntrinsic == Intrinsic::dx_sdot ||
397 DotIntrinsic == Intrinsic::dx_udot);
400 Type *ATy =
A->getType();
401 [[maybe_unused]]
Type *BTy =
B->getType();
411 Intrinsic::ID MadIntrinsic = DotIntrinsic == Intrinsic::dx_sdot
413 : Intrinsic::dx_umad;
416 Result = Builder.CreateMul(Elt0, Elt1);
417 for (
unsigned I = 1;
I < AVec->getNumElements();
I++) {
418 Elt0 = Builder.CreateExtractElement(
A,
I);
419 Elt1 = Builder.CreateExtractElement(
B,
I);
420 Result = Builder.CreateIntrinsic(Result->getType(), MadIntrinsic,
430 Type *Ty =
X->getType();
438 Value *NewX = Builder.CreateFMul(Log2eConst,
X);
440 Builder.CreateIntrinsic(Ty, Intrinsic::exp2, {NewX},
nullptr,
"dx.exp2");
452 switch (TCI->getZExtValue()) {
466 Type *FTy =
F->getType();
467 unsigned FNumElem = 0;
473 Type *ElemTy = FVecTy->getElementType();
474 FNumElem = FVecTy->getNumElements();
475 BitWidth = ElemTy->getPrimitiveSizeInBits();
482 Value *FBitCast = Builder.CreateBitCast(
F, BitCastTy);
483 switch (TCI->getZExtValue()) {
489 Value *NegZeroSplat = Builder.CreateVectorSplat(FNumElem, NegZero);
491 Builder.CreateICmpEQ(FBitCast, NegZeroSplat,
"is.fpclass.negzero");
493 RetVal = Builder.CreateICmpEQ(FBitCast, NegZero,
"is.fpclass.negzero");
505 Type *Ty =
X->getType();
510 if (IntrinsicId == Intrinsic::dx_any)
511 return Builder.CreateOr(Result, Elt);
512 assert(IntrinsicId == Intrinsic::dx_all);
513 return Builder.CreateAnd(Result, Elt);
516 Value *Result =
nullptr;
517 if (!Ty->isVectorTy()) {
519 ? Builder.CreateFCmpUNE(
X, ConstantFP::get(EltTy, 0))
520 : Builder.CreateICmpNE(
X, ConstantInt::get(EltTy, 0));
525 ? Builder.CreateFCmpUNE(
528 ConstantFP::get(EltTy, 0)))
529 : Builder.CreateICmpNE(
532 ConstantInt::get(EltTy, 0)));
533 Result = Builder.CreateExtractElement(
Cond, (
uint64_t)0);
534 for (
unsigned I = 1;
I < XVec->getNumElements();
I++) {
535 Value *Elt = Builder.CreateExtractElement(
Cond,
I);
536 Result = ApplyOp(IntrinsicId, Result, Elt);
547 auto *V = Builder.CreateFSub(
Y,
X);
548 V = Builder.CreateFMul(S, V);
549 return Builder.CreateFAdd(
X, V,
"dx.lerp");
556 Type *Ty =
X->getType();
562 ConstantFP::get(EltTy, LogConstVal))
563 : ConstantFP::get(EltTy, LogConstVal);
565 Builder.CreateIntrinsic(Ty, Intrinsic::log2, {
X},
nullptr,
"elt.log2");
568 return Builder.CreateFMul(Ln2Const, Log2Call);
585 const APFloat &fpVal = constantFP->getValueAPF();
589 return Builder.CreateFDiv(
X,
X);
597 const APFloat &fpVal = constantFP->getValueAPF();
602 Value *Multiplicand = Builder.CreateIntrinsic(EltTy, Intrinsic::dx_rsqrt,
604 nullptr,
"dx.rsqrt");
606 Value *MultiplicandVec =
607 Builder.CreateVectorSplat(XVec->getNumElements(), Multiplicand);
608 return Builder.CreateFMul(
X, MultiplicandVec);
614 Type *Ty =
X->getType();
618 Value *Tan = Builder.CreateFDiv(
Y,
X);
621 Builder.CreateIntrinsic(Ty, Intrinsic::atan, {Tan},
nullptr,
"Elt.Atan");
629 Constant *Zero = ConstantFP::get(Ty, 0);
630 Value *AtanAddPi = Builder.CreateFAdd(Atan, Pi);
631 Value *AtanSubPi = Builder.CreateFSub(Atan, Pi);
634 Value *Result = Atan;
635 Value *XLt0 = Builder.CreateFCmpOLT(
X, Zero);
636 Value *XEq0 = Builder.CreateFCmpOEQ(
X, Zero);
637 Value *YGe0 = Builder.CreateFCmpOGE(
Y, Zero);
638 Value *YLt0 = Builder.CreateFCmpOLT(
Y, Zero);
641 Value *XLt0AndYGe0 = Builder.CreateAnd(XLt0, YGe0);
642 Result = Builder.CreateSelect(XLt0AndYGe0, AtanAddPi, Result);
645 Value *XLt0AndYLt0 = Builder.CreateAnd(XLt0, YLt0);
646 Result = Builder.CreateSelect(XLt0AndYLt0, AtanSubPi, Result);
649 Value *XEq0AndYLt0 = Builder.CreateAnd(XEq0, YLt0);
650 Result = Builder.CreateSelect(XEq0AndYLt0, NegHalfPi, Result);
653 Value *XEq0AndYGe0 = Builder.CreateAnd(XEq0, YGe0);
654 Result = Builder.CreateSelect(XEq0AndYGe0, HalfPi, Result);
663 Type *Ty =
X->getType();
666 if (IntrinsicId == Intrinsic::powi)
667 Y = Builder.CreateSIToFP(
Y, Ty);
670 Builder.CreateIntrinsic(Ty, Intrinsic::log2, {
X},
nullptr,
"elt.log2");
671 auto *
Mul = Builder.CreateFMul(Log2Call,
Y);
673 Builder.CreateIntrinsic(Ty, Intrinsic::exp2, {
Mul},
nullptr,
"elt.exp2");
683 Type *Ty =
X->getType();
686 Constant *One = ConstantFP::get(Ty->getScalarType(), 1.0);
687 Constant *Zero = ConstantFP::get(Ty->getScalarType(), 0.0);
690 if (Ty != Ty->getScalarType()) {
698 return Builder.CreateSelect(
Cond, Zero, One);
703 Type *Ty =
X->getType();
706 return Builder.CreateFMul(
X, PiOver180);
716 "Only expand double or int64 scalars or vectors");
717 bool IsVector =
false;
718 unsigned ExtractNum = 2;
720 ExtractNum = 2 * VT->getNumElements();
722 assert(IsRaw || ExtractNum == 4 &&
"TypedBufferLoad vector must be size 2");
731 while (ExtractNum > 0) {
732 unsigned LoadNum = std::min(ExtractNum, 4u);
736 Intrinsic::ID LoadIntrinsic = Intrinsic::dx_resource_load_typedbuffer;
739 LoadIntrinsic = Intrinsic::dx_resource_load_rawbuffer;
740 Value *Tmp = Builder.getInt32(4 *
Base * 2);
741 Args.push_back(Builder.CreateAdd(Orig->
getOperand(2), Tmp));
744 CallInst *Load = Builder.CreateIntrinsic(LoadType, LoadIntrinsic, Args);
748 Value *Extract = Builder.CreateExtractValue(Load, {0});
751 for (
unsigned I = 0;
I < LoadNum; ++
I)
753 Builder.CreateExtractElement(Extract, Builder.getInt32(
I)));
756 for (
unsigned I = 0;
I < LoadNum;
I += 2) {
757 Value *Combined =
nullptr;
760 Combined = Builder.CreateIntrinsic(
761 Builder.getDoubleTy(), Intrinsic::dx_asdouble,
762 {ExtractElements[I], ExtractElements[I + 1]});
767 Builder.CreateZExt(ExtractElements[
I], Builder.getInt64Ty());
769 Builder.CreateZExt(ExtractElements[
I + 1], Builder.getInt64Ty());
771 Value *ShiftedHi = Builder.CreateShl(
Hi, Builder.getInt64(32));
773 Combined = Builder.CreateOr(
Lo, ShiftedHi);
777 Result = Builder.CreateInsertElement(Result, Combined,
778 Builder.getInt32((
I / 2) +
Base));
783 ExtractNum -= LoadNum;
787 Value *CheckBit =
nullptr;
798 if (Indices[0] == 0) {
800 EVI->replaceAllUsesWith(Result);
803 assert(Indices[0] == 1 &&
"Unexpected type for typedbufferload");
808 for (
Value *L : Loads)
809 CheckBits.
push_back(Builder.CreateExtractValue(L, {1}));
810 CheckBit = Builder.CreateAnd(CheckBits);
812 EVI->replaceAllUsesWith(CheckBit);
814 EVI->eraseFromParent();
823 unsigned ValIndex = IsRaw ? 3 : 2;
828 "Only expand double or int64 scalars or vectors");
831 bool IsVector =
false;
832 unsigned ExtractNum = 2;
835 VecLen = VT->getNumElements();
836 assert(IsRaw || VecLen == 2 &&
"TypedBufferStore vector must be size 2");
837 ExtractNum = VecLen * 2;
850 Value *LowBits =
nullptr;
851 Value *HighBits =
nullptr;
855 Value *Split = Builder.CreateIntrinsic(SplitTy, Intrinsic::dx_splitdouble,
857 LowBits = Builder.CreateExtractValue(Split, 0);
858 HighBits = Builder.CreateExtractValue(Split, 1);
862 Constant *ShiftAmt = Builder.getInt64(32);
868 LowBits = Builder.CreateTrunc(InputVal, SplitElementTy);
869 Value *ShiftedVal = Builder.CreateLShr(InputVal, ShiftAmt);
870 HighBits = Builder.CreateTrunc(ShiftedVal, SplitElementTy);
875 for (
unsigned I = 0;
I < VecLen; ++
I) {
877 Mask.push_back(
I + VecLen);
879 Val = Builder.CreateShuffleVector(LowBits, HighBits, Mask);
881 Val = Builder.CreateInsertElement(Val, LowBits, Builder.getInt32(0));
882 Val = Builder.CreateInsertElement(Val, HighBits, Builder.getInt32(1));
889 while (ExtractNum > 0) {
890 unsigned StoreNum = std::min(ExtractNum, 4u);
892 Intrinsic::ID StoreIntrinsic = Intrinsic::dx_resource_store_typedbuffer;
895 StoreIntrinsic = Intrinsic::dx_resource_store_rawbuffer;
897 Args.push_back(Builder.CreateAdd(Orig->
getOperand(2), Tmp));
901 for (
unsigned I = 0;
I < StoreNum; ++
I) {
902 Mask.push_back(
Base +
I);
907 SubVal = Builder.CreateShuffleVector(Val, Mask);
909 Args.push_back(SubVal);
911 Builder.CreateIntrinsic(Builder.getVoidTy(), StoreIntrinsic, Args);
913 ExtractNum -= StoreNum;
921 if (ClampIntrinsic == Intrinsic::dx_uclamp)
922 return Intrinsic::umax;
923 if (ClampIntrinsic == Intrinsic::dx_sclamp)
924 return Intrinsic::smax;
925 assert(ClampIntrinsic == Intrinsic::dx_nclamp);
926 return Intrinsic::maxnum;
930 if (ClampIntrinsic == Intrinsic::dx_uclamp)
931 return Intrinsic::umin;
932 if (ClampIntrinsic == Intrinsic::dx_sclamp)
933 return Intrinsic::smin;
934 assert(ClampIntrinsic == Intrinsic::dx_nclamp);
935 return Intrinsic::minnum;
943 Type *Ty =
X->getType();
945 auto *MaxCall = Builder.CreateIntrinsic(Ty,
getMaxForClamp(ClampIntrinsic),
946 {
X, Min},
nullptr,
"dx.max");
947 return Builder.CreateIntrinsic(Ty,
getMinForClamp(ClampIntrinsic),
948 {MaxCall, Max},
nullptr,
"dx.min");
953 Type *Ty =
X->getType();
956 return Builder.CreateFMul(
X, DegreesRatio);
961 Type *Ty =
X->getType();
971 GT = Builder.CreateFCmpOLT(Zero,
X);
972 LT = Builder.CreateFCmpOLT(
X, Zero);
975 GT = Builder.CreateICmpSLT(Zero,
X);
976 LT = Builder.CreateICmpSLT(
X, Zero);
979 Value *ZextGT = Builder.CreateZExt(GT, RetTy);
980 Value *ZextLT = Builder.CreateZExt(LT, RetTy);
982 return Builder.CreateSub(ZextGT, ZextLT);
986 Value *Result =
nullptr;
988 switch (IntrinsicId) {
992 case Intrinsic::assume:
995 case Intrinsic::atan2:
1001 case Intrinsic::is_fpclass:
1004 case Intrinsic::log:
1007 case Intrinsic::log10:
1010 case Intrinsic::pow:
1011 case Intrinsic::powi:
1014 case Intrinsic::dx_all:
1015 case Intrinsic::dx_any:
1018 case Intrinsic::dx_cross:
1021 case Intrinsic::dx_uclamp:
1022 case Intrinsic::dx_sclamp:
1023 case Intrinsic::dx_nclamp:
1026 case Intrinsic::dx_degrees:
1029 case Intrinsic::dx_isinf:
1032 case Intrinsic::dx_isnan:
1035 case Intrinsic::dx_lerp:
1038 case Intrinsic::dx_normalize:
1041 case Intrinsic::dx_fdot:
1044 case Intrinsic::dx_sdot:
1045 case Intrinsic::dx_udot:
1048 case Intrinsic::dx_sign:
1051 case Intrinsic::dx_step:
1054 case Intrinsic::dx_radians:
1057 case Intrinsic::dx_resource_load_rawbuffer:
1061 case Intrinsic::dx_resource_store_rawbuffer:
1065 case Intrinsic::dx_resource_load_typedbuffer:
1069 case Intrinsic::dx_resource_store_typedbuffer:
1073 case Intrinsic::usub_sat:
1076 case Intrinsic::vector_reduce_add:
1077 case Intrinsic::vector_reduce_fadd:
1093 bool IntrinsicExpanded =
false;
1100 if (
F.user_empty() && IntrinsicExpanded)
1101 F.eraseFromParent();
1120 "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.