14 #ifndef LLVM_ANALYSIS_TARGETTRANSFORMINFOIMPL_H 15 #define LLVM_ANALYSIS_TARGETTRANSFORMINFOIMPL_H 53 case Instruction::GetElementPtr:
56 case Instruction::BitCast:
57 assert(OpTy &&
"Cast instructions must provide the operand type");
65 case Instruction::FDiv:
66 case Instruction::FRem:
67 case Instruction::SDiv:
68 case Instruction::SRem:
69 case Instruction::UDiv:
70 case Instruction::URem:
73 case Instruction::IntToPtr: {
84 case Instruction::PtrToInt: {
95 case Instruction::Trunc:
109 for (
unsigned Idx = 0,
Size = Operands.
size(); Idx !=
Size; ++Idx)
110 if (!isa<Constant>(Operands[Idx]))
131 assert(FTy &&
"FunctionType must be provided to this routine.");
174 assert(F &&
"A concrete function must be provided to this routine.");
190 if (Name ==
"copysign" || Name ==
"copysignf" || Name ==
"copysignl" ||
191 Name ==
"fabs" || Name ==
"fabsf" || Name ==
"fabsl" || Name ==
"sin" ||
192 Name ==
"fmin" || Name ==
"fminf" || Name ==
"fminl" ||
193 Name ==
"fmax" || Name ==
"fmaxf" || Name ==
"fmaxl" ||
194 Name ==
"sinf" || Name ==
"sinl" || Name ==
"cos" || Name ==
"cosf" ||
195 Name ==
"cosl" || Name ==
"sqrt" || Name ==
"sqrtf" || Name ==
"sqrtl")
199 if (Name ==
"pow" || Name ==
"powf" || Name ==
"powl" || Name ==
"exp2" ||
200 Name ==
"exp2l" || Name ==
"exp2f" || Name ==
"floor" ||
201 Name ==
"floorf" || Name ==
"ceil" || Name ==
"round" ||
202 Name ==
"ffs" || Name ==
"ffsl" || Name ==
"abs" || Name ==
"labs" ||
231 bool HasBaseReg, int64_t Scale,
235 return !BaseGV && BaseOffset == 0 && (Scale == 0 || Scale == 1);
294 bool HasBaseReg, int64_t Scale,
unsigned AddrSpace) {
322 unsigned VF) {
return 0; }
329 bool IsZeroCmp)
const {
343 bool *
Fast) {
return false; }
375 return Vector ? 1 : 0;
381 return "Generic::Unknown Register Class";
382 case 0:
return "Generic::ScalarRC";
383 case 1:
return "Generic::VectorRC";
397 bool &AllowPromotionWithoutCommonHeader) {
398 AllowPromotionWithoutCommonHeader =
false;
478 unsigned Alignment) {
486 bool UseMaskForCond =
false,
487 bool UseMaskForGaps =
false) {
493 unsigned ScalarizationCostPassed) {
532 Type *ExpectedType) {
537 unsigned SrcAlign,
unsigned DestAlign)
const {
543 unsigned RemainingBytes,
545 unsigned DestAlign)
const {
546 for (
unsigned i = 0; i != RemainingBytes; ++i)
584 unsigned AddrSpace)
const {
590 unsigned AddrSpace)
const {
595 unsigned ChainSizeInBytes,
601 unsigned ChainSizeInBytes,
623 if (isa<ConstantDataVector>(Val) || isa<ConstantVector>(Val)) {
624 const auto* VectorValue = cast<Constant>(Val);
628 auto *VT = cast<VectorType>(Val->
getType());
635 unsigned MaxRequiredSize = VT->getBitWidth() / VT->getNumElements();
637 unsigned MinRequiredSize = 0;
638 for(
unsigned i = 0,
e = VT->getNumElements(); i <
e; ++i) {
639 if (
auto* IntElement =
640 dyn_cast<ConstantInt>(VectorValue->getAggregateElement(i))) {
641 bool signedElement = IntElement->getValue().isNegative();
643 unsigned ElementMinRequiredSize =
644 IntElement->getValue().getMinSignedBits() - 1;
646 isSigned |= signedElement;
648 MinRequiredSize =
std::max(MinRequiredSize, ElementMinRequiredSize);
652 return MaxRequiredSize;
655 return MinRequiredSize;
658 if (
const auto* CI = dyn_cast<ConstantInt>(Val)) {
659 isSigned = CI->getValue().isNegative();
660 return CI->getValue().getMinSignedBits() - 1;
663 if (
const auto* Cast = dyn_cast<SExtInst>(Val)) {
665 return Cast->getSrcTy()->getScalarSizeInBits() - 1;
668 if (
const auto* Cast = dyn_cast<ZExtInst>(Val)) {
670 return Cast->getSrcTy()->getScalarSizeInBits();
678 return Ptr && isa<SCEVAddRecExpr>(Ptr);
690 int64_t MergeDistance) {
704 template <
typename T>
713 using BaseT::getCallCost;
716 assert(F &&
"A concrete function must be provided to this routine.");
726 return static_cast<T *
>(
this)
730 if (!static_cast<T *>(
this)->isLoweredToCall(F))
745 using BaseT::getGEPCost;
749 assert(PointeeType && Ptr &&
"can't get GEPCost of nullptr");
753 "explicit pointee type doesn't match operand's pointee type");
755 bool HasBaseReg = (BaseGV ==
nullptr);
758 APInt BaseOffset(PtrSizeBits, 0);
762 Type *TargetType =
nullptr;
766 if (Operands.
empty())
769 for (
auto I = Operands.
begin();
I != Operands.
end(); ++
I, ++GTI) {
770 TargetType = GTI.getIndexedType();
777 if (
StructType *STy = GTI.getStructTypeOrNull()) {
779 assert(ConstIdx &&
"Unexpected GEP index");
798 TargetType, const_cast<GlobalValue *>(BaseGV),
814 case Intrinsic::memcpy:
815 return static_cast<T *
>(
this)->
getMemcpyCost(dyn_cast<Instruction>(U));
817 case Intrinsic::annotation:
818 case Intrinsic::assume:
819 case Intrinsic::sideeffect:
820 case Intrinsic::dbg_declare:
821 case Intrinsic::dbg_value:
822 case Intrinsic::dbg_label:
823 case Intrinsic::invariant_start:
824 case Intrinsic::invariant_end:
825 case Intrinsic::launder_invariant_group:
826 case Intrinsic::strip_invariant_group:
827 case Intrinsic::is_constant:
828 case Intrinsic::lifetime_start:
829 case Intrinsic::lifetime_end:
830 case Intrinsic::objectsize:
831 case Intrinsic::ptr_annotation:
832 case Intrinsic::var_annotation:
833 case Intrinsic::experimental_gc_result:
834 case Intrinsic::experimental_gc_relocate:
835 case Intrinsic::coro_alloc:
836 case Intrinsic::coro_begin:
837 case Intrinsic::coro_free:
838 case Intrinsic::coro_end:
839 case Intrinsic::coro_frame:
840 case Intrinsic::coro_size:
841 case Intrinsic::coro_suspend:
842 case Intrinsic::coro_param:
843 case Intrinsic::coro_subfn_addr:
856 for (
unsigned Idx = 0,
Size = Arguments.
size(); Idx !=
Size; ++Idx)
857 ParamTys.
push_back(Arguments[Idx]->getType());
858 return static_cast<T *
>(
this)->getIntrinsicCost(IID, RetTy, ParamTys, U);
865 if (isa<ExtractValueInst>(U))
869 if (
auto *A = dyn_cast<AllocaInst>(U))
870 if (A->isStaticAlloca())
874 return static_cast<T *
>(
this)->
getGEPCost(
GEP->getSourceElementType(),
875 GEP->getPointerOperand(),
880 const Function *
F = CS.getCalledFunction();
884 return static_cast<T *
>(
this)
885 ->
getCallCost(cast<FunctionType>(FTy), CS.arg_size(), U);
892 if (isa<SExtInst>(U) || isa<ZExtInst>(U) || isa<FPExtInst>(U))
895 return static_cast<T *
>(
this)->
getExtCost(cast<Instruction>(U),
909 if (isa<LoadInst>(I))
916 if (
auto *CI = dyn_cast<CallInst>(I)) {
917 const Function *
F = CI->getCalledFunction();
922 if (
StructType* StructTy = dyn_cast<StructType>(DstTy))
923 DstTy = StructTy->getElementType(0);
927 if (
VectorType *VectorTy = dyn_cast<VectorType>(DstTy))
928 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
const T & back() const
back - Get the last element.
This class represents lattice values for constants.
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
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)
Analysis providing profile information.
value_op_iterator value_op_begin()
The main scalar evolution driver.
A cache of @llvm.assume calls within a function.
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.
TypeSize getTypeSizeInBits(Type *Ty) const
Size examples:
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...
Type * getPointerElementType() const
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.
mir Rename Register Operands
const APInt & getAPInt() const
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.
TypeSize getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type...
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.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
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'.
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
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.
Conditional or Unconditional Branch instruction.
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.
TypeSize getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
unsigned getNumParams() const
Return the number of fixed parameters this function type requires.
AMDGPU Lower Kernel Arguments
param_iterator param_begin() const
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
Attributes of a target dependent hardware loop.
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This struct is a compact representation of a valid (non-zero power of two) alignment.
unsigned getNumOperands() const
This is the shared class of boolean and integer constants.
Align max(MaybeAlign Lhs, Align Rhs)
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...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Provides information about what library functions are available for the current target.
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
Drive the analysis of memory accesses in the loop.
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.
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.
Fast - This calling convention attempts to make calls as fast as possible (e.g.
unsigned getOpcode() const
Return the opcode for this Instruction or ConstantExpr.
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
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)