LLVM  15.0.0git
SystemZTargetTransformInfo.h
Go to the documentation of this file.
1 //===-- SystemZTargetTransformInfo.h - SystemZ-specific TTI ---------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZTARGETTRANSFORMINFO_H
10 #define LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZTARGETTRANSFORMINFO_H
11 
12 #include "SystemZTargetMachine.h"
15 
16 namespace llvm {
17 
18 class SystemZTTIImpl : public BasicTTIImplBase<SystemZTTIImpl> {
20  typedef TargetTransformInfo TTI;
21  friend BaseT;
22 
23  const SystemZSubtarget *ST;
24  const SystemZTargetLowering *TLI;
25 
26  const SystemZSubtarget *getST() const { return ST; }
27  const SystemZTargetLowering *getTLI() const { return TLI; }
28 
29  unsigned const LIBCALL_COST = 30;
30 
31 public:
32  explicit SystemZTTIImpl(const SystemZTargetMachine *TM, const Function &F)
33  : BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)),
34  TLI(ST->getTargetLowering()) {}
35 
36  /// \name Scalar TTI Implementations
37  /// @{
38 
39  unsigned getInliningThresholdMultiplier() { return 3; }
40  unsigned adjustInliningThreshold(const CallBase *CB) const;
41 
44 
45  InstructionCost getIntImmCostInst(unsigned Opcode, unsigned Idx,
46  const APInt &Imm, Type *Ty,
48  Instruction *Inst = nullptr);
50  const APInt &Imm, Type *Ty,
52 
53  TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth);
54 
58 
61 
64  /// @}
65 
66  /// \name Vector TTI Implementations
67  /// @{
68 
69  unsigned getNumberOfRegisters(unsigned ClassID) const;
71 
72  unsigned getCacheLineSize() const override { return 256; }
73  unsigned getPrefetchDistance() const override { return 4500; }
74  unsigned getMinPrefetchStride(unsigned NumMemAccesses,
75  unsigned NumStridedMemAccesses,
76  unsigned NumPrefetches,
77  bool HasCall) const override;
78  bool enableWritePrefetching() const override { return true; }
79 
80  bool hasDivRemOp(Type *DataType, bool IsSigned);
81  bool prefersVectorizedAddressing() { return false; }
82  bool LSRWithInstrQueries() { return true; }
84  bool enableInterleavedAccessVectorization() { return true; }
85 
87  unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
93  const Instruction *CxtI = nullptr);
96  VectorType *SubTp,
98  unsigned getVectorTruncCost(Type *SrcTy, Type *DstTy);
99  unsigned getVectorBitmaskConversionCost(Type *SrcTy, Type *DstTy);
100  unsigned getBoolVecToIntConversionCost(unsigned Opcode, Type *Dst,
101  const Instruction *I);
102  InstructionCost getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
105  const Instruction *I = nullptr);
106  InstructionCost getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy,
107  CmpInst::Predicate VecPred,
109  const Instruction *I = nullptr);
110  InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val,
111  unsigned Index);
112  bool isFoldableLoad(const LoadInst *Ld, const Instruction *&FoldedValue);
113  InstructionCost getMemoryOpCost(unsigned Opcode, Type *Src,
114  MaybeAlign Alignment, unsigned AddressSpace,
116  const Instruction *I = nullptr);
117 
119  unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices,
120  Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind,
121  bool UseMaskForCond = false, bool UseMaskForGaps = false);
122 
125  /// @}
126 };
127 
128 } // end namespace llvm
129 
130 #endif
llvm::SystemZTTIImpl::enableWritePrefetching
bool enableWritePrefetching() const override
Definition: SystemZTargetTransformInfo.h:78
llvm::InstructionCost
Definition: InstructionCost.h:29
llvm::SystemZTTIImpl::enableInterleavedAccessVectorization
bool enableInterleavedAccessVectorization()
Definition: SystemZTargetTransformInfo.h:84
llvm::TargetTransformInfo::TargetCostKind
TargetCostKind
The kind of cost model.
Definition: TargetTransformInfo.h:213
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::SystemZTTIImpl::getBoolVecToIntConversionCost
unsigned getBoolVecToIntConversionCost(unsigned Opcode, Type *Dst, const Instruction *I)
Definition: SystemZTargetTransformInfo.cpp:742
llvm::CmpInst::Predicate
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition: InstrTypes.h:719
llvm::Function
Definition: Function.h:60
llvm::Loop
Represents a single loop in the control flow graph.
Definition: LoopInfo.h:546
llvm::TargetTransformInfo::PopcntSupportKind
PopcntSupportKind
Flags indicating the kind of support for population count.
Definition: TargetTransformInfo.h:601
C1
instcombine should handle this C2 when C1
Definition: README.txt:263
llvm::SystemZTargetLowering
Definition: SystemZISelLowering.h:385
llvm::TargetTransformInfo
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
Definition: TargetTransformInfo.h:170
llvm::ScalarEvolution
The main scalar evolution driver.
Definition: ScalarEvolution.h:449
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::TargetTransformInfo::PeelingPreferences
Definition: TargetTransformInfo.h:544
llvm::SystemZTTIImpl::getShuffleCost
InstructionCost getShuffleCost(TTI::ShuffleKind Kind, VectorType *Tp, ArrayRef< int > Mask, int Index, VectorType *SubTp, ArrayRef< const Value * > Args=None)
Definition: SystemZTargetTransformInfo.cpp:595
llvm::SystemZTTIImpl::getNumberOfRegisters
unsigned getNumberOfRegisters(unsigned ClassID) const
Definition: SystemZTargetTransformInfo.cpp:354
F
#define F(x, y, z)
Definition: MD5.cpp:55
llvm::TargetTransformInfoImplBase::getDataLayout
const DataLayout & getDataLayout() const
Definition: TargetTransformInfoImpl.h:46
llvm::BitmaskEnumDetail::Mask
constexpr std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
Definition: BitmaskEnum.h:80
llvm::SystemZTTIImpl::getVectorInstrCost
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index)
Definition: SystemZTargetTransformInfo.cpp:999
llvm::SystemZTTIImpl::getCastInstrCost
InstructionCost getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src, TTI::CastContextHint CCH, TTI::TargetCostKind CostKind, const Instruction *I=nullptr)
Definition: SystemZTargetTransformInfo.cpp:758
llvm::TargetTransformInfo::OP_None
@ OP_None
Definition: TargetTransformInfo.h:918
llvm::TargetTransformInfo::ShuffleKind
ShuffleKind
The various kinds of shuffle patterns for vector queries.
Definition: TargetTransformInfo.h:891
llvm::TargetTransformInfo::CastContextHint
CastContextHint
Represents a hint about the context in which a cast is used.
Definition: TargetTransformInfo.h:1112
llvm::SystemZTTIImpl::getArithmeticInstrCost
InstructionCost getArithmeticInstrCost(unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind, TTI::OperandValueKind Opd1Info=TTI::OK_AnyValue, TTI::OperandValueKind Opd2Info=TTI::OK_AnyValue, TTI::OperandValueProperties Opd1PropInfo=TTI::OP_None, TTI::OperandValueProperties Opd2PropInfo=TTI::OP_None, ArrayRef< const Value * > Args=ArrayRef< const Value * >(), const Instruction *CxtI=nullptr)
Definition: SystemZTargetTransformInfo.cpp:420
llvm::SystemZTTIImpl::LSRWithInstrQueries
bool LSRWithInstrQueries()
Definition: SystemZTargetTransformInfo.h:82
llvm::dwarf::Index
Index
Definition: Dwarf.h:472
llvm::MaybeAlign
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Definition: Alignment.h:117
llvm::Instruction
Definition: Instruction.h:42
llvm::SystemZTTIImpl::getCacheLineSize
unsigned getCacheLineSize() const override
Definition: SystemZTargetTransformInfo.h:72
llvm::SystemZTTIImpl::getIntrinsicInstrCost
InstructionCost getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA, TTI::TargetCostKind CostKind)
Definition: SystemZTargetTransformInfo.cpp:1241
llvm::Align
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
llvm::AddressSpace
AddressSpace
Definition: NVPTXBaseInfo.h:21
llvm::SystemZTTIImpl::adjustInliningThreshold
unsigned adjustInliningThreshold(const CallBase *CB) const
Definition: SystemZTargetTransformInfo.cpp:52
llvm::SystemZTTIImpl::getCmpSelInstrCost
InstructionCost getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy, CmpInst::Predicate VecPred, TTI::TargetCostKind CostKind, const Instruction *I=nullptr)
Definition: SystemZTargetTransformInfo.cpp:914
llvm::None
const NoneType None
Definition: None.h:24
llvm::lltok::Kind
Kind
Definition: LLToken.h:18
llvm::IntrinsicCostAttributes
Definition: TargetTransformInfo.h:118
llvm::SystemZTTIImpl::getRegisterBitWidth
TypeSize getRegisterBitWidth(TargetTransformInfo::RegisterKind K) const
Definition: SystemZTargetTransformInfo.cpp:366
llvm::VectorType
Base class of all SIMD vector types.
Definition: DerivedTypes.h:389
llvm::SystemZTTIImpl::getPeelingPreferences
void getPeelingPreferences(Loop *L, ScalarEvolution &SE, TTI::PeelingPreferences &PP)
Definition: SystemZTargetTransformInfo.cpp:337
SystemZTargetMachine.h
llvm::TargetTransformInfo::LSRCost
Definition: TargetTransformInfo.h:419
llvm::SystemZTTIImpl::isFoldableLoad
bool isFoldableLoad(const LoadInst *Ld, const Instruction *&FoldedValue)
Definition: SystemZTargetTransformInfo.cpp:1021
llvm::SystemZTTIImpl::getVectorBitmaskConversionCost
unsigned getVectorBitmaskConversionCost(Type *SrcTy, Type *DstTy)
Definition: SystemZTargetTransformInfo.cpp:691
llvm::TargetTransformInfo::UnrollingPreferences
Parameters that control the generic loop unrolling transformation.
Definition: TargetTransformInfo.h:433
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::TargetTransformInfo::OperandValueProperties
OperandValueProperties
Additional properties of an operand's values.
Definition: TargetTransformInfo.h:918
llvm::SystemZTTIImpl::getVectorTruncCost
unsigned getVectorTruncCost(Type *SrcTy, Type *DstTy)
Definition: SystemZTargetTransformInfo.cpp:649
llvm::SystemZTargetMachine
Definition: SystemZTargetMachine.h:27
llvm::BasicTTIImplBase
Base class which can be used to help build a TTI implementation.
Definition: BasicTTIImpl.h:77
llvm::SystemZTTIImpl::isLSRCostLess
bool isLSRCostLess(const TargetTransformInfo::LSRCost &C1, const TargetTransformInfo::LSRCost &C2)
Definition: SystemZTargetTransformInfo.cpp:342
llvm::SystemZSubtarget
Definition: SystemZSubtarget.h:33
llvm::SystemZTTIImpl
Definition: SystemZTargetTransformInfo.h:18
llvm::TargetTransformInfo::OperandValueKind
OperandValueKind
Additional information about an operand's possible values.
Definition: TargetTransformInfo.h:910
llvm::APInt
Class for arbitrary precision integers.
Definition: APInt.h:75
llvm::SystemZTTIImpl::SystemZTTIImpl
SystemZTTIImpl(const SystemZTargetMachine *TM, const Function &F)
Definition: SystemZTargetTransformInfo.h:32
llvm::SystemZTTIImpl::getIntImmCost
InstructionCost getIntImmCost(const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind)
Definition: SystemZTargetTransformInfo.cpp:69
llvm::SystemZTTIImpl::getInliningThresholdMultiplier
unsigned getInliningThresholdMultiplier()
Definition: SystemZTargetTransformInfo.h:39
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::SystemZTTIImpl::getIntImmCostIntrin
InstructionCost getIntImmCostIntrin(Intrinsic::ID IID, unsigned Idx, const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind)
Definition: SystemZTargetTransformInfo.cpp:223
llvm::OptimizationRemarkEmitter
The optimization diagnostic interface.
Definition: OptimizationRemarkEmitter.h:33
CostKind
static cl::opt< TargetTransformInfo::TargetCostKind > CostKind("cost-kind", cl::desc("Target cost kind"), cl::init(TargetTransformInfo::TCK_RecipThroughput), cl::values(clEnumValN(TargetTransformInfo::TCK_RecipThroughput, "throughput", "Reciprocal throughput"), clEnumValN(TargetTransformInfo::TCK_Latency, "latency", "Instruction latency"), clEnumValN(TargetTransformInfo::TCK_CodeSize, "code-size", "Code size"), clEnumValN(TargetTransformInfo::TCK_SizeAndLatency, "size-latency", "Code size and latency")))
getParent
static const Function * getParent(const Value *V)
Definition: BasicAliasAnalysis.cpp:845
llvm::TargetTransformInfo::OK_AnyValue
@ OK_AnyValue
Definition: TargetTransformInfo.h:911
llvm::LoadInst
An instruction for reading from memory.
Definition: Instructions.h:174
llvm::SystemZTTIImpl::getInterleavedMemoryOpCost
InstructionCost getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef< unsigned > Indices, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, bool UseMaskForCond=false, bool UseMaskForGaps=false)
Definition: SystemZTargetTransformInfo.cpp:1179
llvm::SystemZTTIImpl::getMinPrefetchStride
unsigned getMinPrefetchStride(unsigned NumMemAccesses, unsigned NumStridedMemAccesses, unsigned NumPrefetches, bool HasCall) const override
Definition: SystemZTargetTransformInfo.cpp:379
llvm::TypeSize
Definition: TypeSize.h:435
llvm::SystemZTTIImpl::getMemoryOpCost
InstructionCost getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, const Instruction *I=nullptr)
Definition: SystemZTargetTransformInfo.cpp:1108
llvm::SystemZTTIImpl::getPrefetchDistance
unsigned getPrefetchDistance() const override
Definition: SystemZTargetTransformInfo.h:73
llvm::RISCVMatInt::Imm
@ Imm
Definition: RISCVMatInt.h:23
llvm::TargetTransformInfo::RegisterKind
RegisterKind
Definition: TargetTransformInfo.h:939
llvm::SystemZTTIImpl::supportsEfficientVectorElementLoadStore
bool supportsEfficientVectorElementLoadStore()
Definition: SystemZTargetTransformInfo.h:83
TargetTransformInfo.h
llvm::SystemZTTIImpl::getPopcntSupport
TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth)
Definition: SystemZTargetTransformInfo.cpp:274
llvm::CallBase
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition: InstrTypes.h:1174
llvm::SystemZTTIImpl::getIntImmCostInst
InstructionCost getIntImmCostInst(unsigned Opcode, unsigned Idx, const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind, Instruction *Inst=nullptr)
Definition: SystemZTargetTransformInfo.cpp:102
TM
const char LLVMTargetMachineRef TM
Definition: PassBuilderBindings.cpp:47
llvm::SystemZTTIImpl::prefersVectorizedAddressing
bool prefersVectorizedAddressing()
Definition: SystemZTargetTransformInfo.h:81
llvm::AMDGPU::HSAMD::Kernel::Key::Args
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Definition: AMDGPUMetadata.h:394
BasicTTIImpl.h
llvm::SystemZTTIImpl::hasDivRemOp
bool hasDivRemOp(Type *DataType, bool IsSigned)
Definition: SystemZTargetTransformInfo.cpp:396
llvm::SystemZTTIImpl::getUnrollingPreferences
void getUnrollingPreferences(Loop *L, ScalarEvolution &SE, TTI::UnrollingPreferences &UP, OptimizationRemarkEmitter *ORE)
Definition: SystemZTargetTransformInfo.cpp:281
llvm::Intrinsic::ID
unsigned ID
Definition: TargetTransformInfo.h:38