15 #ifndef LLVM_ANALYSIS_TARGETTRANSFORMINFOIMPL_H 16 #define LLVM_ANALYSIS_TARGETTRANSFORMINFOIMPL_H 54 case Instruction::GetElementPtr:
57 case Instruction::BitCast:
58 assert(OpTy &&
"Cast instructions must provide the operand type");
66 case Instruction::FDiv:
67 case Instruction::FRem:
68 case Instruction::SDiv:
69 case Instruction::SRem:
70 case Instruction::UDiv:
71 case Instruction::URem:
74 case Instruction::IntToPtr: {
85 case Instruction::PtrToInt: {
96 case Instruction::Trunc:
110 for (
unsigned Idx = 0,
Size = Operands.
size(); Idx !=
Size; ++Idx)
111 if (!isa<Constant>(Operands[Idx]))
128 assert(FTy &&
"FunctionType must be provided to this routine.");
196 assert(F &&
"A concrete function must be provided to this routine.");
212 if (Name ==
"copysign" || Name ==
"copysignf" || Name ==
"copysignl" ||
213 Name ==
"fabs" || Name ==
"fabsf" || Name ==
"fabsl" || Name ==
"sin" ||
214 Name ==
"fmin" || Name ==
"fminf" || Name ==
"fminl" ||
215 Name ==
"fmax" || Name ==
"fmaxf" || Name ==
"fmaxl" ||
216 Name ==
"sinf" || Name ==
"sinl" || Name ==
"cos" || Name ==
"cosf" ||
217 Name ==
"cosl" || Name ==
"sqrt" || Name ==
"sqrtf" || Name ==
"sqrtl")
221 if (Name ==
"pow" || Name ==
"powf" || Name ==
"powl" || Name ==
"exp2" ||
222 Name ==
"exp2l" || Name ==
"exp2f" || Name ==
"floor" ||
223 Name ==
"floorf" || Name ==
"ceil" || Name ==
"round" ||
224 Name ==
"ffs" || Name ==
"ffsl" || Name ==
"abs" || Name ==
"labs" ||
239 bool HasBaseReg, int64_t Scale,
243 return !BaseGV && BaseOffset == 0 && (Scale == 0 || Scale == 1);
272 bool HasBaseReg, int64_t Scale,
unsigned AddrSpace) {
304 unsigned VF) {
return 0; }
311 bool IsZeroCmp)
const {
325 bool *
Fast) {
return false; }
366 bool &AllowPromotionWithoutCommonHeader) {
367 AllowPromotionWithoutCommonHeader =
false;
449 unsigned Alignment) {
457 bool UseMaskForCond =
false,
458 bool UseMaskForGaps =
false) {
464 unsigned ScalarizationCostPassed) {
503 Type *ExpectedType) {
508 unsigned SrcAlign,
unsigned DestAlign)
const {
514 unsigned RemainingBytes,
516 unsigned DestAlign)
const {
517 for (
unsigned i = 0; i != RemainingBytes; ++i)
555 unsigned AddrSpace)
const {
561 unsigned AddrSpace)
const {
566 unsigned ChainSizeInBytes,
572 unsigned ChainSizeInBytes,
590 if (isa<ConstantDataVector>(Val) || isa<ConstantVector>(Val)) {
591 const auto* VectorValue = cast<Constant>(Val);
595 auto *VT = cast<VectorType>(Val->
getType());
602 unsigned MaxRequiredSize = VT->getBitWidth() / VT->getNumElements();
604 unsigned MinRequiredSize = 0;
605 for(
unsigned i = 0, e = VT->getNumElements(); i < e; ++i) {
606 if (
auto* IntElement =
607 dyn_cast<ConstantInt>(VectorValue->getAggregateElement(i))) {
608 bool signedElement = IntElement->getValue().isNegative();
610 unsigned ElementMinRequiredSize =
611 IntElement->getValue().getMinSignedBits() - 1;
613 isSigned |= signedElement;
615 MinRequiredSize =
std::max(MinRequiredSize, ElementMinRequiredSize);
619 return MaxRequiredSize;
622 return MinRequiredSize;
625 if (
const auto* CI = dyn_cast<ConstantInt>(Val)) {
626 isSigned = CI->getValue().isNegative();
627 return CI->getValue().getMinSignedBits() - 1;
630 if (
const auto* Cast = dyn_cast<SExtInst>(Val)) {
632 return Cast->getSrcTy()->getScalarSizeInBits() - 1;
635 if (
const auto* Cast = dyn_cast<ZExtInst>(Val)) {
637 return Cast->getSrcTy()->getScalarSizeInBits();
645 return Ptr && isa<SCEVAddRecExpr>(Ptr);
657 int64_t MergeDistance) {
671 template <
typename T>
680 using BaseT::getCallCost;
683 assert(F &&
"A concrete function must be provided to this routine.");
693 return static_cast<T *
>(
this)
697 if (!static_cast<T *>(
this)->isLoweredToCall(F))
711 using BaseT::getGEPCost;
716 if (Ptr !=
nullptr) {
720 "explicit pointee type doesn't match operand's pointee type");
723 bool HasBaseReg = (BaseGV ==
nullptr);
726 APInt BaseOffset(PtrSizeBits, 0);
730 Type *TargetType =
nullptr;
734 if (Operands.
empty())
737 for (
auto I = Operands.
begin();
I != Operands.
end(); ++
I, ++GTI) {
738 TargetType = GTI.getIndexedType();
745 if (
StructType *STy = GTI.getStructTypeOrNull()) {
747 assert(ConstIdx &&
"Unexpected GEP index");
769 if (static_cast<T *>(
this)->isLegalAddressingMode(
770 TargetType, const_cast<GlobalValue *>(BaseGV),
776 using BaseT::getIntrinsicCost;
785 for (
unsigned Idx = 0,
Size = Arguments.
size(); Idx !=
Size; ++Idx)
786 ParamTys.
push_back(Arguments[Idx]->getType());
795 if (
auto *A = dyn_cast<AllocaInst>(U))
796 if (A->isStaticAlloca())
800 return static_cast<T *
>(
this)->
getGEPCost(
GEP->getSourceElementType(),
801 GEP->getPointerOperand(),
806 const Function *
F = CS.getCalledFunction();
810 return static_cast<T *
>(
this)
811 ->
getCallCost(cast<FunctionType>(FTy), CS.arg_size());
818 if (
const CastInst *CI = dyn_cast<CastInst>(U)) {
822 if (isa<CmpInst>(CI->getOperand(0)))
824 if (isa<SExtInst>(CI) || isa<ZExtInst>(CI) || isa<FPExtInst>(CI))
825 return static_cast<T *>(
this)->getExtCost(CI, Operands.
back());
839 if (isa<LoadInst>(I))
846 if (
auto *CI = dyn_cast<CallInst>(I)) {
847 const Function *
F = CI->getCalledFunction();
852 if (
StructType* StructTy = dyn_cast<StructType>(DstTy))
853 DstTy = StructTy->getElementType(0);
857 if (
VectorType *VectorTy = dyn_cast<VectorType>(DstTy))
858 DstTy = VectorTy->getElementType();
unsigned getNumCases() const
Return the number of 'cases' in this switch instruction, excluding the default case.
bool isIntrinsic() const
isIntrinsic - Returns true if the function's name starts with "llvm.".
A parsed version of the target data layout string in and methods for querying it. ...
bool hasLocalLinkage() const
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
const T & back() const
back - Get the last element.
This class represents lattice values for constants.
const Value * getSplatValue(const Value *V)
Get splat value if the input is a splat vector or return nullptr.
const StructLayout * getStructLayout(StructType *Ty) const
Returns a StructLayout object, indicating the alignment of the struct, its size, and the offsets of i...
void push_back(const T &Elt)
value_op_iterator value_op_begin()
The main scalar evolution driver.
value_op_iterator value_op_end()
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
param_iterator param_end() const
An instruction for reading from memory.
void reserve(size_type N)
unsigned getBitWidth() const
Return the number of bits in the APInt.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
amdgpu Simplify well known AMD library false Value Value const Twine & Name
Type * getPointerElementType() const
This is the base class for all instructions that perform data casts.
unsigned getPointerTypeSizeInBits(Type *) const
Layout pointer size, in bits, based on the type.
bool isFloatingPointTy() const
Return true if this is one of the six floating-point types.
Class to represent struct types.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
const APInt & getAPInt() const
Fast - This calling convention attempts to make calls as fast as possible (e.g.
Class to represent function types.
int64_t getSExtValue() const
Get sign extended value.
Type * getType() const
All values are typed, get the type of this value.
This node represents a polynomial recurrence on the trip count of the specified loop.
APInt sextOrTrunc(unsigned width) const
Sign extend or truncate to width.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
const APInt & getValue() const
Return the constant as an APInt value reference.
An instruction for storing to memory.
const SCEV * getStepRecurrence(ScalarEvolution &SE) const
Constructs and returns the recurrence indicating how much this expression steps by.
Value * getOperand(unsigned i) const
Analysis containing CSE Info
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
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.
size_t size() const
size - Get the array size.
This is an important base class in LLVM.
bool isPointerTy() const
True if this is an instance of PointerType.
unsigned getNumParams() const
Return the number of fixed parameters this function type requires.
AMDGPU Lower Kernel Arguments
param_iterator param_begin() const
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs, and aliases.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned getNumOperands() const
This is the shared class of boolean and integer constants.
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
bool isLegalInteger(uint64_t Width) const
Returns true if the specified type is known to be a native integer type supported by the CPU...
Type * getReturnType() const
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
FunctionType * getFunctionType() const
Returns the FunctionType for me.
Class to represent vector types.
Class for arbitrary precision integers.
amdgpu Simplify well known AMD library false Value Value * Arg
uint64_t getTypeSizeInBits(Type *Ty) const
Size examples:
uint64_t getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
uint64_t getElementOffset(unsigned Idx) const
This class represents an analyzed expression in the program.
Represents a single loop in the control flow graph.
ArrayRef< T > drop_front(size_t N=1) const
Drop the first N elements of the array.
StringRef getName() const
Return a constant reference to the value's name.
Establish a view to a call site for examination.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
unsigned getOpcode() const
Return the opcode for this Instruction or ConstantExpr.
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
Convenience struct for specifying and reasoning about fast-math flags.
StringRef - Represent a constant reference to a string, i.e.
Information about a load/store intrinsic defined by the target.
static IntegerType * getInt8Ty(LLVMContext &C)
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
bool empty() const
empty - Check if the array is empty.
A wrapper class for inspecting calls to intrinsic functions.
This class represents a constant integer value.
gep_type_iterator gep_type_begin(const User *GEP)