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::dbg_declare:
156 case Intrinsic::dbg_value:
157 case Intrinsic::invariant_start:
158 case Intrinsic::invariant_end:
159 case Intrinsic::lifetime_start:
160 case Intrinsic::lifetime_end:
161 case Intrinsic::objectsize:
162 case Intrinsic::ptr_annotation:
163 case Intrinsic::var_annotation:
164 case Intrinsic::experimental_gc_result:
165 case Intrinsic::experimental_gc_relocate:
166 case Intrinsic::coro_alloc:
167 case Intrinsic::coro_begin:
168 case Intrinsic::coro_free:
169 case Intrinsic::coro_end:
170 case Intrinsic::coro_frame:
171 case Intrinsic::coro_size:
172 case Intrinsic::coro_suspend:
173 case Intrinsic::coro_param:
174 case Intrinsic::coro_subfn_addr:
205 if (Name ==
"copysign" || Name ==
"copysignf" || Name ==
"copysignl" ||
206 Name ==
"fabs" || Name ==
"fabsf" || Name ==
"fabsl" || Name ==
"sin" ||
207 Name ==
"fmin" || Name ==
"fminf" || Name ==
"fminl" ||
208 Name ==
"fmax" || Name ==
"fmaxf" || Name ==
"fmaxl" ||
209 Name ==
"sinf" || Name ==
"sinl" || Name ==
"cos" || Name ==
"cosf" ||
210 Name ==
"cosl" || Name ==
"sqrt" || Name ==
"sqrtf" || Name ==
"sqrtl")
214 if (Name ==
"pow" || Name ==
"powf" || Name ==
"powl" || Name ==
"exp2" ||
215 Name ==
"exp2l" || Name ==
"exp2f" || Name ==
"floor" ||
216 Name ==
"floorf" || Name ==
"ceil" || Name ==
"round" ||
217 Name ==
"ffs" || Name ==
"ffsl" || Name ==
"abs" || Name ==
"labs" ||
232 bool HasBaseReg, int64_t Scale,
233 unsigned AddrSpace) {
236 return !BaseGV && BaseOffset == 0 && (Scale == 0 || Scale == 1);
257 bool HasBaseReg, int64_t Scale,
unsigned AddrSpace) {
285 unsigned VF) {
return 0; }
301 bool *
Fast) {
return false; }
336 bool &AllowPromotionWithoutCommonHeader) {
337 AllowPromotionWithoutCommonHeader =
false;
396 unsigned Alignment) {
410 unsigned ScalarizationCostPassed) {
447 Type *ExpectedType) {
452 unsigned SrcAlign,
unsigned DestAlign)
const {
458 unsigned RemainingBytes,
460 unsigned DestAlign)
const {
461 for (
unsigned i = 0; i != RemainingBytes; ++i)
481 unsigned AddrSpace)
const {
487 unsigned AddrSpace)
const {
492 unsigned ChainSizeInBytes,
498 unsigned ChainSizeInBytes,
516 if (isa<ConstantDataVector>(Val) || isa<ConstantVector>(Val)) {
517 const auto* VectorValue = cast<Constant>(Val);
521 auto *VT = cast<VectorType>(Val->
getType());
528 unsigned MaxRequiredSize = VT->getBitWidth() / VT->getNumElements();
530 unsigned MinRequiredSize = 0;
531 for(
unsigned i = 0, e = VT->getNumElements(); i < e; ++i) {
532 if (
auto* IntElement =
533 dyn_cast<ConstantInt>(VectorValue->getAggregateElement(i))) {
534 bool signedElement = IntElement->getValue().isNegative();
536 unsigned ElementMinRequiredSize =
537 IntElement->getValue().getMinSignedBits() - 1;
539 isSigned |= signedElement;
541 MinRequiredSize =
std::max(MinRequiredSize, ElementMinRequiredSize);
545 return MaxRequiredSize;
548 return MinRequiredSize;
551 if (
const auto* CI = dyn_cast<ConstantInt>(Val)) {
552 isSigned = CI->getValue().isNegative();
553 return CI->getValue().getMinSignedBits() - 1;
556 if (
const auto* Cast = dyn_cast<SExtInst>(Val)) {
558 return Cast->getSrcTy()->getScalarSizeInBits() - 1;
561 if (
const auto* Cast = dyn_cast<ZExtInst>(Val)) {
563 return Cast->getSrcTy()->getScalarSizeInBits();
571 return Ptr && isa<SCEVAddRecExpr>(
Ptr);
583 int64_t MergeDistance) {
597 template <
typename T>
609 assert(F &&
"A concrete function must be provided to this routine.");
619 return static_cast<T *
>(
this)
623 if (!static_cast<T *>(
this)->isLoweredToCall(F))
642 if (Ptr !=
nullptr) {
646 "explicit pointee type doesn't match operand's pointee type");
649 bool HasBaseReg = (BaseGV ==
nullptr);
650 int64_t BaseOffset = 0;
655 for (
auto I = Operands.
begin();
I != Operands.
end(); ++
I, ++GTI) {
656 TargetType = GTI.getIndexedType();
663 if (
StructType *STy = GTI.getStructTypeOrNull()) {
665 assert(ConstIdx &&
"Unexpected GEP index");
685 if (static_cast<T *>(
this)->isLegalAddressingMode(
686 TargetType, const_cast<GlobalValue *>(BaseGV), BaseOffset,
687 HasBaseReg, Scale, AS))
701 for (
unsigned Idx = 0,
Size = Arguments.
size(); Idx !=
Size; ++Idx)
702 ParamTys.
push_back(Arguments[Idx]->getType());
711 return static_cast<T *
>(
this)->
getGEPCost(
GEP->getSourceElementType(),
712 GEP->getPointerOperand(),
717 const Function *
F = CS.getCalledFunction();
720 Type *FTy = CS.getCalledValue()->getType()->getPointerElementType();
721 return static_cast<T *
>(
this)
722 ->
getCallCost(cast<FunctionType>(FTy), CS.arg_size());
726 return static_cast<T *
>(
this)->
getCallCost(F, Arguments);
729 if (
const CastInst *CI = dyn_cast<CastInst>(U)) {
733 if (isa<CmpInst>(CI->getOperand(0)))
735 if (isa<SExtInst>(CI) || isa<ZExtInst>(CI) || isa<FPExtInst>(CI))
736 return static_cast<T *>(
this)->getExtCost(CI, Operands.
back());
void push_back(const T &Elt)
A parsed version of the target data layout string in and methods for querying it. ...
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
unsigned getNumParams() const
Return the number of fixed parameters this function type requires.
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs, and aliases.
const Value * getSplatValue(const Value *V)
Get splat value if the input is a splat vector or return nullptr.
unsigned getNumOperands() const
unsigned getPointerTypeSizeInBits(Type *) const
Layout pointer size, in bits, based on the type.
The main scalar evolution driver.
bool isIntrinsic() const
isIntrinsic - Returns true if the function's name starts with "llvm.".
const SCEV * getStepRecurrence(ScalarEvolution &SE) const
Constructs and returns the recurrence indicating how much this expression steps by.
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
An instruction for reading from memory.
void reserve(size_type N)
Type * getPointerElementType() const
StringRef getName() const
Return a constant reference to the value's name.
const StructLayout * getStructLayout(StructType *Ty) const
Returns a StructLayout object, indicating the alignment of the struct, its size, and the offsets of i...
This is the base class for all instructions that perform data casts.
Class to represent struct types.
param_iterator param_end() const
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
Class to represent function types.
This node represents a polynomial recurrence on the trip count of the specified loop.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
An instruction for storing to memory.
size_t size() const
size - Get the array size.
uint64_t getElementOffset(unsigned Idx) const
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.
FunctionType * getFunctionType() const
Returns the FunctionType for me.
This is an important base class in LLVM.
int64_t getSExtValue() const
Get sign extended value.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
param_iterator param_begin() const
unsigned getBitWidth() const
Return the number of bits in the APInt.
Value * getOperand(unsigned i) const
const APInt & getAPInt() const
bool isPointerTy() const
True if this is an instance of PointerType.
const T & back() const
back - Get the last element.
This is the shared class of boolean and integer constants.
uint64_t getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
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...
Type * getType() const
All values are typed, get the type of this value.
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
Class to represent vector types.
Class for arbitrary precision integers.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
llvm_unreachable("Unknown RegBank!")
unsigned getOpcode() const
Return the opcode for this Instruction or ConstantExpr.
static std::vector< std::string > Flags
This class represents an analyzed expression in the program.
Represents a single loop in the control flow graph.
Establish a view to a call site for examination.
Fast - This calling convention attempts to make calls as fast as possible (e.g.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
unsigned getNumCases() const
Return the number of 'cases' in this switch instruction, excluding the default case.
bool hasLocalLinkage() const
Type * getReturnType() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ArrayRef< T > drop_front(size_t N=1) const
Drop the first N elements of the array.
LLVM Value Representation.
uint64_t getTypeSizeInBits(Type *Ty) const
Size examples:
Convenience struct for specifying and reasoning about fast-math flags.
StringRef - Represent a constant reference to a string, i.e.
bool isLegalInteger(uint64_t Width) const
Returns true if the specified type is known to be a native integer type supported by the CPU...
int64_t getSExtValue() const
Return the constant as a 64-bit integer value after it has been sign extended as appropriate for the ...
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
Information about a load/store intrinsic defined by the target.
static IntegerType * getInt8Ty(LLVMContext &C)
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)