39 #define DEBUG_TYPE "amdgpu-simplifylib" 44 cl::desc(
"Enable pre-link mode optimizations"),
49 cl::desc(
"Comma separated list of functions to replace with native, or all"),
53 #define MATH_PI numbers::pi 54 #define MATH_E numbers::e 55 #define MATH_SQRT2 numbers::sqrt2 56 #define MATH_SQRT1_2 numbers::inv_sqrt2 68 bool AllNative =
false;
77 bool replaceWithNative(
CallInst *
CI,
const FuncInfo &FInfo);
79 bool parseFunctionName(
const StringRef& FMangledName,
80 FuncInfo *FInfo=
nullptr );
82 bool TDOFold(
CallInst *CI,
const FuncInfo &FInfo);
102 bool sincosUseNative(
CallInst *aCI,
const FuncInfo &FInfo);
105 bool evaluateScalarMathFunc(FuncInfo &FInfo,
double& Res0,
107 bool evaluateCall(
CallInst *aCI, FuncInfo &FInfo);
214 "Simplify well-known AMD library calls",
false,
false)
217 "Simplify well-known AMD library
calls",
false, false)
220 "Replace builtin math calls with that native versions.",
223 template <typename IRB>
226 CallInst *R = B.CreateCall(Callee, Arg, Name);
227 if (
Function *
F = dyn_cast<Function>(Callee.getCallee()))
232 template <
typename IRB>
424 TableRef(
const TableEntry (&tbl)[
N]) : size(N), table(&tbl[0]) {}
487 bool AMDGPULibCalls::parseFunctionName(
const StringRef& FMangledName,
493 if (
auto Op = dyn_cast<FPMathOperator>(CI))
501 bool AMDGPULibCalls::useNativeFunc(
const StringRef F)
const {
507 AllNative = useNativeFunc(
"all") ||
512 bool AMDGPULibCalls::sincosUseNative(
CallInst *aCI,
const FuncInfo &FInfo) {
513 bool native_sin = useNativeFunc(
"sin");
514 bool native_cos = useNativeFunc(
"cos");
516 if (native_sin && native_cos) {
531 if (sinExpr && cosExpr) {
537 <<
" with native version of sin/cos");
554 !(AllNative || useNativeFunc(FInfo.
getName()))) {
559 return sincosUseNative(aCI, FInfo);
568 <<
" with native version");
582 if (!Callee->isDeclaration())
585 assert(Callee->hasName() &&
"Invalid read_pipe/write_pipe function");
586 auto *M = Callee->getParent();
587 auto &Ctx = M->getContext();
588 std::string
Name = Callee->getName();
590 if (NumArg != 4 && NumArg != 6)
594 if (!isa<ConstantInt>(PacketSize) || !isa<ConstantInt>(PacketAlign))
596 unsigned Size = cast<ConstantInt>(PacketSize)->getZExtValue();
597 unsigned Align = cast<ConstantInt>(PacketAlign)->getZExtValue();
612 for (
unsigned I = 0;
I != PtrArgLoc; ++
I)
626 for (
unsigned I = 0;
I != PtrArgLoc; ++
I)
645 if (Callee == 0)
return false;
655 if (
const FPMathOperator *FPOp = dyn_cast<const FPMathOperator>(CI))
661 case Intrinsic::amdgcn_wavefrontsize:
666 if (!parseFunctionName(Callee->
getName(), &FInfo))
673 if (TDOFold(CI, FInfo))
683 switch (FInfo.
getId()) {
688 "recip must be an either native or half function");
695 "divide must be an either native or half function");
701 return fold_pow(CI, B, FInfo);
720 return fold_sincos(CI, B, AA);
727 return fold_read_write_pipe(CI, B, FInfo);
742 int const sz = (int)tr.
size;
743 const TableEntry *
const ftbl = tr.
table;
749 for (
int eltNo = 0; eltNo <
getVecSize(FInfo); ++eltNo) {
751 CV->getElementAsConstant((
unsigned)eltNo));
752 assert(eltval &&
"Non-FP arguments in math function!");
754 for (
int i=0; i < sz; ++i) {
770 for (
unsigned i = 0; i < DVal.
size(); ++i) {
779 LLVM_DEBUG(
errs() <<
"AMDIC: " << *CI <<
" ---> " << *nval <<
"\n");
785 if (
ConstantFP *CF = dyn_cast<ConstantFP>(opr0)) {
786 for (
int i = 0; i < sz; ++i) {
787 if (CF->isExactlyValue(ftbl[i].input)) {
789 LLVM_DEBUG(
errs() <<
"AMDIC: " << *CI <<
" ---> " << *nval <<
"\n");
800 bool AMDGPULibCalls::replaceWithNative(
CallInst *CI,
const FuncInfo &FInfo) {
825 if (
ConstantFP *CF = dyn_cast<ConstantFP>(opr0)) {
832 LLVM_DEBUG(
errs() <<
"AMDIC: " << *CI <<
" ---> " << *nval <<
"\n");
852 opr1,
"__div2recip");
862 #if _XOPEN_SOURCE >= 600 || defined(_ISOC99_SOURCE) || _POSIX_C_SOURCE >= 200112L 871 const FuncInfo &FInfo) {
875 "fold_pow: encounter a wrong function call");
892 assert(VTy &&
"Oprand of vector function should be of vectortype");
897 CF = CDV ? dyn_cast_or_null<ConstantFP>(CDV->
getSplatValue()) :
nullptr;
898 CINT = CDV ? dyn_cast_or_null<ConstantInt>(CDV->
getSplatValue()) :
nullptr;
906 int ci_opr1 = (CINT ? (int)CINT->
getSExtValue() : 0x1111111);
908 if ((CF && CF->
isZero()) || (CINT && ci_opr1 == 0) || CZero) {
920 LLVM_DEBUG(
errs() <<
"AMDIC: " << *CI <<
" ---> " << *opr0 <<
"\n");
926 LLVM_DEBUG(
errs() <<
"AMDIC: " << *CI <<
" ---> " << *opr0 <<
" * " << *opr0
932 if ((CF && CF->
isExactlyValue(-1.0)) || (CINT && ci_opr1 == -1)) {
934 LLVM_DEBUG(
errs() <<
"AMDIC: " << *CI <<
" ---> 1 / " << *opr0 <<
"\n");
953 << FInfo.
getName().c_str() <<
"(" << *opr0 <<
")\n");
954 Value *nval = CreateCallEx(B,FPExpr, opr0, issqrt ?
"__pow2sqrt" 971 int ival = (int)dval;
972 if ((
double)ival == dval) {
975 ci_opr1 = 0x11111111;
980 unsigned abs_opr1 = (ci_opr1 < 0) ? -ci_opr1 : ci_opr1;
981 if (abs_opr1 <= 12) {
991 Value *valx2 =
nullptr;
993 while (abs_opr1 > 0) {
994 valx2 = valx2 ? B.
CreateFMul(valx2, valx2,
"__powx2") : opr0;
996 nval = nval ? B.
CreateFMul(nval, valx2,
"__powprod") : valx2;
1007 nval = B.
CreateFDiv(cnval, nval,
"__1powprod");
1010 << ((ci_opr1 < 0) ?
"1/prod(" :
"prod(") << *opr0
1023 bool needlog =
false;
1024 bool needabs =
false;
1025 bool needcopysign =
false;
1052 "Wrong vector size detected");
1059 if (V < 0.0) needcopysign =
true;
1065 for (
unsigned i=0; i < DVal.size(); ++i) {
1081 if (
const ConstantFP *CF = dyn_cast<ConstantFP>(opr1)) {
1085 if (y != (
double)(int64_t)y)
1093 ? (
double)CDV->getElementAsFloat(i)
1094 : CDV->getElementAsDouble(i);
1095 if (y != (
double)(int64_t)y)
1109 nval = CreateCallEx(B, AbsExpr, opr0,
"__fabs");
1111 nval = cnval ? cnval : opr0;
1118 nval = CreateCallEx(B,LogExpr, nval,
"__log2");
1126 nval = CreateCallEx(B,ExpExpr, nval,
"__exp2");
1133 if (
const VectorType *vTy = dyn_cast<VectorType>(rTy))
1149 <<
"exp2(" << *opr1 <<
" * log2(" << *opr0 <<
"))\n");
1156 const FuncInfo &FInfo) {
1166 LLVM_DEBUG(
errs() <<
"AMDIC: " << *CI <<
" ---> " << *opr0 <<
"\n");
1174 LLVM_DEBUG(
errs() <<
"AMDIC: " << *CI <<
" ---> sqrt(" << *opr0 <<
")\n");
1175 Value *nval = CreateCallEx(B,FPExpr, opr0,
"__rootn2sqrt");
1179 }
else if (ci_opr1 == 3) {
1183 LLVM_DEBUG(
errs() <<
"AMDIC: " << *CI <<
" ---> cbrt(" << *opr0 <<
")\n");
1184 Value *nval = CreateCallEx(B,FPExpr, opr0,
"__rootn2cbrt");
1188 }
else if (ci_opr1 == -1) {
1189 LLVM_DEBUG(
errs() <<
"AMDIC: " << *CI <<
" ---> 1.0 / " << *opr0 <<
"\n");
1195 }
else if (ci_opr1 == -2) {
1201 Value *nval = CreateCallEx(B,FPExpr, opr0,
"__rootn2rsqrt");
1210 const FuncInfo &FInfo) {
1217 if ((CF0 && CF0->
isZero()) || (CF1 && CF1->isZero())) {
1219 LLVM_DEBUG(
errs() <<
"AMDIC: " << *CI <<
" ---> " << *opr2 <<
"\n");
1225 LLVM_DEBUG(
errs() <<
"AMDIC: " << *CI <<
" ---> " << *opr1 <<
" + " << *opr2
1231 if (CF1 && CF1->isExactlyValue(1.0f)) {
1233 LLVM_DEBUG(
errs() <<
"AMDIC: " << *CI <<
" ---> " << *opr0 <<
" + " << *opr2
1239 if (
ConstantFP *CF = dyn_cast<ConstantFP>(opr2)) {
1242 LLVM_DEBUG(
errs() <<
"AMDIC: " << *CI <<
" ---> " << *opr0 <<
" * " 1255 const FuncInfo &FInfo) {
1258 FuncInfo nf = FInfo;
1260 return getFunction(M, nf);
1265 const FuncInfo &FInfo) {
1272 <<
"sqrt(" << *opr0 <<
")\n");
1273 Value *nval = CreateCallEx(B,FPExpr, opr0,
"__sqrt");
1295 int const MaxScan = 30;
1313 std::string
const PairName = fInfo.
mangle();
1317 CallInst *XI = dyn_cast_or_null<CallInst>(U);
1318 if (!XI || XI == CI || XI->
getParent() != CBB)
1329 for (
int I = MaxScan;
I > 0 && BBI != CBB->
begin(); --BBI, --
I) {
1330 if (cast<Instruction>(BBI) == XI) {
1338 if (!UI)
return false;
1347 if (!Fsincos)
return false;
1350 AllocaInst *Alloc = insertAlloca(UI, B,
"__sincos_");
1362 LLVM_DEBUG(
errs() <<
"AMDIC: fold_sincos (" << *CI <<
", " << *UI <<
") with " 1387 StringRef Features = TM->getTargetFeatureString();
1389 (Features.
empty() ||
1397 LLVM_DEBUG(
errs() <<
"AMDIC: fold_wavefrontsize (" << *CI <<
") with " 1409 assert(BB &&
"Entry block not found!");
1416 const char *prefix) {
1422 std::string(prefix) + UI->
getName());
1428 bool AMDGPULibCalls::evaluateScalarMathFunc(FuncInfo &FInfo,
1429 double& Res0,
double& Res1,
1435 double opr0=0.0, opr1=0.0, opr2=0.0;
1436 ConstantFP *fpopr0 = dyn_cast_or_null<ConstantFP>(copr0);
1437 ConstantFP *fpopr1 = dyn_cast_or_null<ConstantFP>(copr1);
1438 ConstantFP *fpopr2 = dyn_cast_or_null<ConstantFP>(copr2);
1447 ? fpopr1->getValueAPF().convertToDouble()
1448 : (double)fpopr1->getValueAPF().convertToFloat();
1453 ? fpopr2->getValueAPF().convertToDouble()
1454 : (double)fpopr2->getValueAPF().convertToFloat();
1457 switch (FInfo.getId()) {
1458 default :
return false;
1466 Res0 = log(opr0 + sqrt(opr0*opr0 - 1.0));
1479 Res0 = log(opr0 + sqrt(opr0*opr0 + 1.0));
1492 Res0 = (log(opr0 + 1.0) - log(opr0 - 1.0))/2.0;
1500 Res0 = (opr0 < 0.0) ? -pow(-opr0, 1.0/3.0) : pow(opr0, 1.0/3.0);
1520 Res0 = pow(2.0, opr0);
1524 Res0 = pow(10.0, opr0);
1528 Res0 = exp(opr0) - 1.0;
1536 Res0 = log(opr0) / log(2.0);
1540 Res0 = log(opr0) / log(10.0);
1544 Res0 = 1.0 / sqrt(opr0);
1586 Res0 = pow(opr0, opr1);
1590 if (
ConstantInt *iopr1 = dyn_cast_or_null<ConstantInt>(copr1)) {
1591 double val = (double)iopr1->getSExtValue();
1592 Res0 = pow(opr0, val);
1599 if (
ConstantInt *iopr1 = dyn_cast_or_null<ConstantInt>(copr1)) {
1600 double val = (double)iopr1->getSExtValue();
1601 Res0 = pow(opr0, 1.0 / val);
1616 Res0 = opr0 * opr1 + opr2;
1623 bool AMDGPULibCalls::evaluateCall(
CallInst *aCI, FuncInfo &FInfo) {
1632 if ((copr0 = dyn_cast<Constant>(aCI->
getArgOperand(0))) ==
nullptr)
1637 if ((copr1 = dyn_cast<Constant>(aCI->
getArgOperand(1))) ==
nullptr) {
1644 if ((copr2 = dyn_cast<Constant>(aCI->
getArgOperand(2))) ==
nullptr)
1651 double DVal0[16], DVal1[16];
1654 if (!evaluateScalarMathFunc(FInfo, DVal0[0],
1655 DVal1[0], copr0, copr1, copr2)) {
1664 Constant *celt1 = CDV1 ? CDV1->getElementAsConstant(i) :
nullptr;
1665 Constant *celt2 = CDV2 ? CDV2->getElementAsConstant(i) :
nullptr;
1666 if (!evaluateScalarMathFunc(FInfo, DVal0[i],
1667 DVal1[i], celt0, celt1, celt2)) {
1686 if (hasTwoResults) {
1695 if (hasTwoResults) {
1702 if (hasTwoResults) {
1705 "math function with ptr arg not supported yet");
1716 return new AMDGPUSimplifyLibCalls(Opt, TM);
1720 return new AMDGPUUseNativeCalls();
1744 if (skipFunction(F))
1747 bool Changed =
false;
1748 auto AA = &getAnalysis<AAResultsWrapperPass>().getAAResults();
1756 for (
auto &BB : F) {
1765 if (Callee == 0)
continue;
1769 if(Simplifier.fold(CI, AA))
1777 if (skipFunction(F) ||
UseNative.empty())
1780 bool Changed =
false;
1781 for (
auto &BB : F) {
1790 if (Callee == 0)
continue;
1792 if(Simplifier.useNative(CI))
A vector constant whose element type is a simple 1/2/4/8-byte integer or float/double, and whose elements are just simple data values (i.e.
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
static const TableEntry tbl_sqrt[]
static const TableEntry tbl_log10[]
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
AllocaInst * CreateAlloca(Type *Ty, unsigned AddrSpace, Value *ArraySize=nullptr, const Twine &Name="")
AMDGPU specific subclass of TargetSubtarget.
void dropAllReferences()
Drop all references to operands.
Value * CreateAddrSpaceCast(Value *V, Type *DestTy, const Twine &Name="")
This class represents lattice values for constants.
Type * getParamType(unsigned i) const
Parameter type accessors.
Constant * getElementAsConstant(unsigned i) const
Return a Constant for a specified index's element.
LoadInst * CreateLoad(Type *Ty, Value *Ptr, const char *Name)
Provided to resolve 'CreateLoad(Ty, Ptr, "...")' correctly, instead of converting the string to 'bool...
LLVM_NODISCARD bool equals_lower(StringRef RHS) const
equals_lower - Check for string equality, ignoring case.
A Module instance is used to store all the information related to an LLVM module. ...
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
static const TableEntry tbl_cospi[]
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
static const TableEntry tbl_cbrt[]
static bool parse(StringRef MangledName, AMDGPULibFunc &Ptr)
void push_back(const T &Elt)
void initializeAMDGPUSimplifyLibCallsPass(PassRegistry &)
This class represents a function call, abstracting a target machine's calling convention.
static PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space...
bool isUnsafeMath(const CallInst *CI) const
float convertToFloat() const
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
An instruction for reading from memory.
static const TableEntry tbl_erf[]
static IntegerType * getInt64Ty(LLVMContext &C)
AttrBuilder & addAttribute(Attribute::AttrKind Val)
Add an attribute to the builder.
void setPrefix(ENamePrefix PFX)
LLVMContext & getContext() const
Get the context in which this basic block lives.
Address space for flat memory.
static const TableEntry tbl_acosh[]
static FunctionCallee getOrInsertFunction(llvm::Module *M, const AMDGPULibFunc &fInfo)
iterator begin()
Instruction iterator methods.
#define DEBUG_WITH_TYPE(TYPE, X)
DEBUG_WITH_TYPE macro - This macro should be used by passes to emit debug information.
IntegerType * getInt32Ty()
Fetch the type representing a 32-bit integer.
Value * getArgOperand(unsigned i) const
static const TableEntry tbl_atanh[]
std::string getName() const
Get unmangled name for mangled library function and name for unmangled library function.
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
bool hasAttributes() const
Return true if the builder has IR-level attributes.
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
IntegerType * getInt64Ty()
Fetch the type representing a 64-bit integer.
Value * FindAvailableLoadedValue(LoadInst *Load, BasicBlock *ScanBB, BasicBlock::iterator &ScanFrom, unsigned MaxInstsToScan=DefMaxInstsToScan, AliasAnalysis *AA=nullptr, bool *IsLoadCSE=nullptr, unsigned *NumScanedInst=nullptr)
Scan backwards to see if we have the value of the given load available locally within a small number ...
LLVMContext & getContext() const
Get the global data context.
bool isIntegerTy() const
True if this is an instance of IntegerType.
Param * getLeads()
Get leading parameters for mangled lib functions.
static const TableEntry tbl_sinh[]
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
unsigned getNumArgs() const
INITIALIZE_PASS_BEGIN(AMDGPUSimplifyLibCalls, "amdgpu-simplifylib", "Simplify well-known AMD library calls", false, false) INITIALIZE_PASS_END(AMDGPUSimplifyLibCalls
All zero aggregate value.
Value * CreateBitCast(Value *V, Type *DestTy, const Twine &Name="")
unsigned NoNaNsFPMath
NoNaNsFPMath - This flag is enabled when the -enable-no-nans-fp-math flag is specified on the command...
Type * getType() const
All values are typed, get the type of this value.
amdgpu Simplify well known AMD library false
static const TableEntry tbl_sinpi[]
void setCalledFunction(Function *Fn)
Sets the function called, including updating the function type.
bool isNegative() const
Return true if the sign bit is set.
static const TableEntry tbl_asinh[]
static const TableEntry tbl_tanpi[]
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Value * CreateSIToFP(Value *V, Type *DestTy, const Twine &Name="")
An instruction for storing to memory.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
Value * CreateZExtOrBitCast(Value *V, Type *DestTy, const Twine &Name="")
void SetInsertPoint(BasicBlock *TheBB)
This specifies that created instructions should be appended to the end of the specified block...
static const TableEntry tbl_log2[]
Value * CreateOr(Value *LHS, Value *RHS, const Twine &Name="")
static AMDGPULibFunc::EType getArgType(const AMDGPULibFunc &FInfo)
const BasicBlock & getEntryBlock() const
static bool runOnFunction(Function &F, bool PostInlining)
initializer< Ty > init(const Ty &Val)
TableRef(const TableEntry(&tbl)[N])
Type * getReturnType() const
Returns the type of the ret val.
bool fold(CallInst *CI, AliasAnalysis *AA=nullptr)
unsigned UnsafeFPMath
UnsafeFPMath - This flag is enabled when the -enable-unsafe-fp-math flag is specified on the command ...
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
Value * CreateFMul(Value *L, Value *R, const Twine &Name="", MDNode *FPMD=nullptr)
static const TableEntry tbl_exp2[]
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
LLVM Basic Block Representation.
static Function * getFunction(llvm::Module *M, const AMDGPULibFunc &fInfo)
Constant * getSplatValue() const
If this is a splat constant, meaning that all of the elements have the same value, return that value.
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This is an important base class in LLVM.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
TypeSize getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
ConstantFP - Floating Point Values [float, double].
static cl::opt< bool > EnablePreLink("amdgpu-prelink", cl::desc("Enable pre-link mode optimizations"), cl::init(false), cl::Hidden)
double convertToDouble() const
float getElementAsFloat(unsigned i) const
If this is an sequential container of floats, return the specified element as a float.
static const TableEntry tbl_atan[]
static const TableEntry tbl_sin[]
Represent the analysis usage information of a pass.
static const TableEntry tbl_rsqrt[]
static const TableEntry tbl_acospi[]
void setCallingConv(CallingConv::ID CC)
FunctionPass class - This class is used to implement most global optimizations.
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
static FunctionType * get(Type *Result, ArrayRef< Type *> Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
Wrapper class for AMDGPULIbFuncImpl.
static const TableEntry tbl_expm1[]
self_iterator getIterator()
static int getVecSize(const AMDGPULibFunc &FInfo)
static Constant * getSplat(unsigned NumElts, Constant *Elt)
Return a ConstantVector with the specified constant in each element.
unsigned NoInfsFPMath
NoInfsFPMath - This flag is enabled when the -enable-no-infs-fp-math flag is specified on the command...
static double log2(double V)
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
static unsigned getEPtrKindFromAddrSpace(unsigned AS)
void initializeAMDGPUUseNativeCallsPass(PassRegistry &)
auto find(R &&Range, const T &Val) -> decltype(adl_begin(Range))
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly...
void printAsOperand(raw_ostream &O, bool PrintType=true, const Module *M=nullptr) const
Print the name of this Value out to the specified raw_ostream.
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
This struct is a compact representation of a valid (non-zero power of two) alignment.
static const TableEntry tbl_atanpi[]
Type * getAllocatedType() const
Return the type that is being allocated by the instruction.
const APFloat & getValueAPF() const
unsigned getWavefrontSize() const
static const TableEntry tbl_exp10[]
AMDGPULibCalls(const TargetMachine *TM_=nullptr)
Iterator for intrusive lists based on ilist_node.
This is the shared class of boolean and integer constants.
static const TableEntry tbl_asinpi[]
static bool setFastFlags(Function &F, const TargetOptions &Options)
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type...
This struct is a compact representation of a valid (power of two) or undefined (0) alignment...
ENamePrefix getPrefix() const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Utility class for floating point operations which can have information about relaxed accuracy require...
Module.h This file contains the declarations for the Module class.
LLVM_NODISCARD size_t find_lower(char C, size_t From=0) const
Search for the first character C in the string, ignoring case.
static IntegerType * getIntNTy(LLVMContext &C, unsigned N)
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
static Constant * get(Type *Ty, double V)
This returns a ConstantFP, or a vector containing a splat of a ConstantFP, for the specified value in...
AttributeList getAttributes() const
Return the parameter attributes for this call.
static const TableEntry tbl_log[]
void setAlignment(MaybeAlign Align)
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Class to represent vector types.
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
static const TableEntry tbl_cosh[]
amdgpu Simplify well known AMD library false FunctionCallee Callee
iterator_range< user_iterator > users()
InstListType::iterator iterator
Instruction iterators...
Value * CreateShl(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Value * CreatePointerCast(Value *V, Type *DestTy, const Twine &Name="")
LLVM_NODISCARD bool equals(StringRef RHS) const
equals - Check for string equality, this is more efficient than compare() when the relative ordering ...
unsigned getNumUses() const
This method computes the number of uses of this Value.
unsigned getNumArgOperands() const
static const TableEntry tbl_exp[]
StringRef getValueAsString() const
Return the attribute's value as a string.
static const TableEntry tbl_tanh[]
bool isZero() const
Return true if the value is positive or negative zero.
static VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
double getElementAsDouble(unsigned i) const
If this is an sequential container of doubles, return the specified element as a double.
StringRef getName() const
Return a constant reference to the value's name.
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation.
const Function * getParent() const
Return the enclosing method, or null if none.
static TableRef getOptTable(AMDGPULibFunc::EFuncId id)
APFloat abs(APFloat X)
Returns the absolute value of the argument.
static const TableEntry tbl_asin[]
Value * CreateFPToSI(Value *V, Type *DestTy, const Twine &Name="")
void setAttributes(AttributeList A)
Set the parameter attributes for this call.
FunctionType * getFunctionType()
static cl::list< std::string > UseNative("amdgpu-use-native", cl::desc("Comma separated list of functions to replace with native, or all"), cl::CommaSeparated, cl::ValueOptional, cl::Hidden)
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value *> Args=None, const Twine &Name="", MDNode *FPMathTag=nullptr)
Address space for private memory.
static const TableEntry tbl_tan[]
static const TableEntry tbl_cos[]
Value * CreateFAdd(Value *L, Value *R, const Twine &Name="", MDNode *FPMD=nullptr)
Value * CreateAnd(Value *LHS, Value *RHS, const Twine &Name="")
static bool HasNative(AMDGPULibFunc::EFuncId id)
Value * CreateFDiv(Value *L, Value *R, const Twine &Name="", MDNode *FPMD=nullptr)
const std::string to_string(const T &Value)
void replaceCall(Value *With)
void addAttributes(unsigned i, const AttrBuilder &Attrs)
adds the attributes to the list of attributes.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
FunctionPass * createAMDGPUSimplifyLibCallsPass(const TargetOptions &, const TargetMachine *)
FunctionPass * createAMDGPUUseNativeCallsPass()
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
amdgpu Simplify well known AMD library calls
static const TableEntry tbl_erfc[]
void setFastMathFlags(FastMathFlags NewFMF)
Set the fast-math flags to be used with generated fp-math operators.
BasicBlock::iterator GetInsertPoint() const
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
std::string mangle() const
Primary interface to the complete machine description for the target machine.
Type * getElementType() const
bool isExactlyValue(const APFloat &V) const
We don't rely on operator== working on double values, as it returns true for things that are clearly ...
StringRef - Represent a constant reference to a string, i.e.
unsigned getNumElements() const
Return the number of elements in the array or vector.
A wrapper pass to provide the legacy pass manager access to a suitably prepared AAResults object...
int64_t getSExtValue() const
Return the constant as a 64-bit integer value after it has been sign extended as appropriate for the ...
static Constant * get(LLVMContext &Context, ArrayRef< uint8_t > Elts)
get() constructors - Return a constant with vector type with an element count and element type matchi...
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
static const TableEntry tbl_tgamma[]
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
bool useNative(CallInst *CI)
static const TableEntry tbl_acos[]
const BasicBlock * getParent() const
an instruction to allocate memory on the stack