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]))
118 assert(FTy &&
"FunctionType must be provided to this routine.");
143 case Intrinsic::annotation:
144 case Intrinsic::assume:
145 case Intrinsic::dbg_declare:
146 case Intrinsic::dbg_value:
147 case Intrinsic::invariant_start:
148 case Intrinsic::invariant_end:
149 case Intrinsic::lifetime_start:
150 case Intrinsic::lifetime_end:
151 case Intrinsic::objectsize:
152 case Intrinsic::ptr_annotation:
153 case Intrinsic::var_annotation:
154 case Intrinsic::experimental_gc_result:
155 case Intrinsic::experimental_gc_relocate:
156 case Intrinsic::coro_alloc:
157 case Intrinsic::coro_begin:
158 case Intrinsic::coro_free:
159 case Intrinsic::coro_end:
160 case Intrinsic::coro_frame:
161 case Intrinsic::coro_size:
162 case Intrinsic::coro_suspend:
163 case Intrinsic::coro_param:
164 case Intrinsic::coro_subfn_addr:
189 if (Name ==
"copysign" || Name ==
"copysignf" || Name ==
"copysignl" ||
190 Name ==
"fabs" || Name ==
"fabsf" || Name ==
"fabsl" || Name ==
"sin" ||
191 Name ==
"fmin" || Name ==
"fminf" || Name ==
"fminl" ||
192 Name ==
"fmax" || Name ==
"fmaxf" || Name ==
"fmaxl" ||
193 Name ==
"sinf" || Name ==
"sinl" || Name ==
"cos" || Name ==
"cosf" ||
194 Name ==
"cosl" || Name ==
"sqrt" || Name ==
"sqrtf" || Name ==
"sqrtl")
198 if (Name ==
"pow" || Name ==
"powf" || Name ==
"powl" || Name ==
"exp2" ||
199 Name ==
"exp2l" || Name ==
"exp2f" || Name ==
"floor" ||
200 Name ==
"floorf" || Name ==
"ceil" || Name ==
"round" ||
201 Name ==
"ffs" || Name ==
"ffsl" || Name ==
"abs" || Name ==
"labs" ||
215 bool HasBaseReg, int64_t Scale,
216 unsigned AddrSpace) {
219 return !BaseGV && BaseOffset == 0 && (Scale == 0 || Scale == 1);
231 bool HasBaseReg, int64_t Scale,
unsigned AddrSpace) {
264 bool *
Fast) {
return false; }
348 unsigned Alignment) {
389 Type *ExpectedType) {
409 unsigned AddrSpace)
const {
415 unsigned AddrSpace)
const {
420 unsigned ChainSizeInBytes,
426 unsigned ChainSizeInBytes,
434 if (isa<ConstantDataVector>(Val) || isa<ConstantVector>(Val)) {
435 const auto* VectorValue = cast<Constant>(Val);
439 auto *VT = cast<VectorType>(Val->
getType());
446 unsigned MaxRequiredSize = VT->getBitWidth() / VT->getNumElements();
448 unsigned MinRequiredSize = 0;
449 for(
unsigned i = 0, e = VT->getNumElements();
i < e; ++
i) {
450 if (
auto* IntElement =
451 dyn_cast<ConstantInt>(VectorValue->getAggregateElement(
i))) {
452 bool signedElement = IntElement->getValue().isNegative();
454 unsigned ElementMinRequiredSize =
455 IntElement->getValue().getMinSignedBits() - 1;
457 isSigned |= signedElement;
459 MinRequiredSize = std::max(MinRequiredSize, ElementMinRequiredSize);
463 return MaxRequiredSize;
466 return MinRequiredSize;
469 if (
const auto* CI = dyn_cast<ConstantInt>(Val)) {
470 isSigned = CI->getValue().isNegative();
471 return CI->getValue().getMinSignedBits() - 1;
474 if (
const auto* Cast = dyn_cast<SExtInst>(Val)) {
476 return Cast->getSrcTy()->getScalarSizeInBits() - 1;
479 if (
const auto* Cast = dyn_cast<ZExtInst>(Val)) {
481 return Cast->getSrcTy()->getScalarSizeInBits();
489 return Ptr && isa<SCEVAddRecExpr>(
Ptr);
501 int64_t MergeDistance) {
515 template <
typename T>
527 assert(F &&
"A concrete function must be provided to this routine.");
537 return static_cast<T *
>(
this)
541 if (!static_cast<T *>(
this)->isLoweredToCall(F))
560 if (Ptr !=
nullptr) {
564 "explicit pointee type doesn't match operand's pointee type");
567 bool HasBaseReg = (BaseGV ==
nullptr);
568 int64_t BaseOffset = 0;
573 for (
auto I = Operands.
begin();
I != Operands.
end(); ++
I, ++GTI) {
574 TargetType = GTI.getIndexedType();
581 if (
StructType *STy = GTI.getStructTypeOrNull()) {
583 assert(ConstIdx &&
"Unexpected GEP index");
603 if (static_cast<T *>(
this)->isLegalAddressingMode(
604 TargetType, const_cast<GlobalValue *>(BaseGV), BaseOffset,
605 HasBaseReg, Scale, AS))
619 for (
unsigned Idx = 0, Size = Arguments.
size(); Idx != Size; ++Idx)
620 ParamTys.
push_back(Arguments[Idx]->getType());
631 GEP->getSourceElementType(),
GEP->getPointerOperand(), Indices);
635 const Function *
F = CS.getCalledFunction();
638 Type *FTy = CS.getCalledValue()->getType()->getPointerElementType();
639 return static_cast<T *
>(
this)
640 ->
getCallCost(cast<FunctionType>(FTy), CS.arg_size());
644 return static_cast<T *
>(
this)->
getCallCost(F, Arguments);
647 if (
const CastInst *CI = dyn_cast<CastInst>(U)) {
651 if (isa<CmpInst>(CI->getOperand(0)))
void push_back(const T &Elt)
A parsed version of the target data layout string in and methods for querying it. ...
unsigned getNumParams() const
Return the number of fixed parameters this function type requires.
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.
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
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.
Type * getScalarType() const LLVM_READONLY
If this is a vector type, return the element type, otherwise return 'this'.
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.
This is an important base class in LLVM.
int64_t getSExtValue() const
Get sign extended value.
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.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
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.
Value * stripPointerCasts()
Strip off pointer casts, all-zero GEPs, and aliases.
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
Class to represent vector types.
Class for arbitrary precision integers.
unsigned getOpcode() const
Return the opcode for this Instruction or ConstantExpr.
This class represents an analyzed expression in the program.
Represents a single loop in the control flow graph.
ImmutableCallSite - establish a view to a call site for examination.
FunctionType * getFunctionType() const
Returns the FunctionType for me.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
bool hasLocalLinkage() const
Type * getReturnType() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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.
Fast - This calling convention attempts to make calls as fast as possible (e.g.
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)