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.");
153 case Intrinsic::annotation:
154 case Intrinsic::assume:
155 case Intrinsic::sideeffect:
156 case Intrinsic::dbg_declare:
157 case Intrinsic::dbg_value:
158 case Intrinsic::dbg_label:
159 case Intrinsic::invariant_start:
160 case Intrinsic::invariant_end:
161 case Intrinsic::lifetime_start:
162 case Intrinsic::lifetime_end:
163 case Intrinsic::objectsize:
164 case Intrinsic::ptr_annotation:
165 case Intrinsic::var_annotation:
166 case Intrinsic::experimental_gc_result:
167 case Intrinsic::experimental_gc_relocate:
168 case Intrinsic::coro_alloc:
169 case Intrinsic::coro_begin:
170 case Intrinsic::coro_free:
171 case Intrinsic::coro_end:
172 case Intrinsic::coro_frame:
173 case Intrinsic::coro_size:
174 case Intrinsic::coro_suspend:
175 case Intrinsic::coro_param:
176 case Intrinsic::coro_subfn_addr:
193 assert(F &&
"A concrete function must be provided to this routine.");
209 if (Name ==
"copysign" || Name ==
"copysignf" || Name ==
"copysignl" ||
210 Name ==
"fabs" || Name ==
"fabsf" || Name ==
"fabsl" || Name ==
"sin" ||
211 Name ==
"fmin" || Name ==
"fminf" || Name ==
"fminl" ||
212 Name ==
"fmax" || Name ==
"fmaxf" || Name ==
"fmaxl" ||
213 Name ==
"sinf" || Name ==
"sinl" || Name ==
"cos" || Name ==
"cosf" ||
214 Name ==
"cosl" || Name ==
"sqrt" || Name ==
"sqrtf" || Name ==
"sqrtl")
218 if (Name ==
"pow" || Name ==
"powf" || Name ==
"powl" || Name ==
"exp2" ||
219 Name ==
"exp2l" || Name ==
"exp2f" || Name ==
"floor" ||
220 Name ==
"floorf" || Name ==
"ceil" || Name ==
"round" ||
221 Name ==
"ffs" || Name ==
"ffsl" || Name ==
"abs" || Name ==
"labs" ||
236 bool HasBaseReg, int64_t Scale,
240 return !BaseGV && BaseOffset == 0 && (Scale == 0 || Scale == 1);
269 bool HasBaseReg, int64_t Scale,
unsigned AddrSpace) {
301 unsigned VF) {
return 0; }
308 bool IsZeroCmp)
const {
320 bool *
Fast) {
return false; }
361 bool &AllowPromotionWithoutCommonHeader) {
362 AllowPromotionWithoutCommonHeader =
false;
444 unsigned Alignment) {
458 unsigned ScalarizationCostPassed) {
497 Type *ExpectedType) {
502 unsigned SrcAlign,
unsigned DestAlign)
const {
508 unsigned RemainingBytes,
510 unsigned DestAlign)
const {
511 for (
unsigned i = 0; i != RemainingBytes; ++i)
541 unsigned AddrSpace)
const {
547 unsigned AddrSpace)
const {
552 unsigned ChainSizeInBytes,
558 unsigned ChainSizeInBytes,
576 if (isa<ConstantDataVector>(Val) || isa<ConstantVector>(Val)) {
577 const auto* VectorValue = cast<Constant>(Val);
581 auto *VT = cast<VectorType>(Val->
getType());
588 unsigned MaxRequiredSize = VT->getBitWidth() / VT->getNumElements();
590 unsigned MinRequiredSize = 0;
591 for(
unsigned i = 0, e = VT->getNumElements(); i < e; ++i) {
592 if (
auto* IntElement =
593 dyn_cast<ConstantInt>(VectorValue->getAggregateElement(i))) {
594 bool signedElement = IntElement->getValue().isNegative();
596 unsigned ElementMinRequiredSize =
597 IntElement->getValue().getMinSignedBits() - 1;
599 isSigned |= signedElement;
601 MinRequiredSize =
std::max(MinRequiredSize, ElementMinRequiredSize);
605 return MaxRequiredSize;
608 return MinRequiredSize;
611 if (
const auto* CI = dyn_cast<ConstantInt>(Val)) {
612 isSigned = CI->getValue().isNegative();
613 return CI->getValue().getMinSignedBits() - 1;
616 if (
const auto* Cast = dyn_cast<SExtInst>(Val)) {
618 return Cast->getSrcTy()->getScalarSizeInBits() - 1;
621 if (
const auto* Cast = dyn_cast<ZExtInst>(Val)) {
623 return Cast->getSrcTy()->getScalarSizeInBits();
631 return Ptr && isa<SCEVAddRecExpr>(Ptr);
643 int64_t MergeDistance) {
657 template <
typename T>
666 using BaseT::getCallCost;
669 assert(F &&
"A concrete function must be provided to this routine.");
679 return static_cast<T *
>(
this)
683 if (!static_cast<T *>(
this)->isLoweredToCall(F))
697 using BaseT::getGEPCost;
702 if (Ptr !=
nullptr) {
706 "explicit pointee type doesn't match operand's pointee type");
709 bool HasBaseReg = (BaseGV ==
nullptr);
712 APInt BaseOffset(PtrSizeBits, 0);
716 Type *TargetType =
nullptr;
720 if (Operands.
empty())
723 for (
auto I = Operands.
begin();
I != Operands.
end(); ++
I, ++GTI) {
724 TargetType = GTI.getIndexedType();
731 if (
StructType *STy = GTI.getStructTypeOrNull()) {
733 assert(ConstIdx &&
"Unexpected GEP index");
755 if (static_cast<T *>(
this)->isLegalAddressingMode(
756 TargetType, const_cast<GlobalValue *>(BaseGV),
762 using BaseT::getIntrinsicCost;
771 for (
unsigned Idx = 0,
Size = Arguments.
size(); Idx !=
Size; ++Idx)
772 ParamTys.
push_back(Arguments[Idx]->getType());
781 if (
auto *A = dyn_cast<AllocaInst>(U))
782 if (A->isStaticAlloca())
786 return static_cast<T *
>(
this)->
getGEPCost(
GEP->getSourceElementType(),
787 GEP->getPointerOperand(),
792 const Function *
F = CS.getCalledFunction();
796 return static_cast<T *
>(
this)
797 ->
getCallCost(cast<FunctionType>(FTy), CS.arg_size());
804 if (
const CastInst *CI = dyn_cast<CastInst>(U)) {
808 if (isa<CmpInst>(CI->getOperand(0)))
810 if (isa<SExtInst>(CI) || isa<ZExtInst>(CI) || isa<FPExtInst>(CI))
811 return static_cast<T *>(
this)->getExtCost(CI, Operands.
back());
825 if (isa<LoadInst>(I))
832 if (
auto *CI = dyn_cast<CallInst>(I)) {
833 const Function *
F = CI->getCalledFunction();
838 if (
StructType* StructTy = dyn_cast<StructType>(DstTy))
839 DstTy = StructTy->getElementType(0);
843 if (
VectorType *VectorTy = dyn_cast<VectorType>(DstTy))
844 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.".
void push_back(const T &Elt)
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.
Compute iterated dominance frontiers using a linear time algorithm.
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...
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.
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
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.
amdgpu Simplify well known AMD library false Value * Callee
Value * getOperand(unsigned i) const
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.
Fast - This calling convention attempts to make calls as fast as possible (e.g.
#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.
static bool isSigned(Value *V)
Can the given value generate sign bits.
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.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
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.
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
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)