LLVM 23.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
15
16namespace llvm {
17
18class SystemZTTIImpl final : 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 bool isInt128InVR(Type *Ty) const {
32 return Ty->isIntegerTy(128) && ST->hasVector();
33 }
34
35public:
36 explicit SystemZTTIImpl(const SystemZTargetMachine *TM, const Function &F)
37 : BaseT(TM, F.getDataLayout()), ST(TM->getSubtargetImpl(F)),
38 TLI(ST->getTargetLowering()) {}
39
40 /// \name Scalar TTI Implementations
41 /// @{
42
43 unsigned adjustInliningThreshold(const CallBase *CB) const override;
44
46 TTI::TargetCostKind CostKind) const override;
47
48 InstructionCost getIntImmCostInst(unsigned Opcode, unsigned Idx,
49 const APInt &Imm, Type *Ty,
51 Instruction *Inst = nullptr) const override;
53 getIntImmCostIntrin(Intrinsic::ID IID, unsigned Idx, const APInt &Imm,
54 Type *Ty, TTI::TargetCostKind CostKind) const override;
55
56 TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth) const override;
57
60 OptimizationRemarkEmitter *ORE) const override;
61
63 TTI::PeelingPreferences &PP) const override;
64
66 const TargetTransformInfo::LSRCost &C2) const override;
67
68 /// @}
69
70 /// \name Vector TTI Implementations
71 /// @{
72
73 unsigned getNumberOfRegisters(unsigned ClassID) const override;
76
77 unsigned getCacheLineSize() const override { return 256; }
78 unsigned getPrefetchDistance() const override { return 4500; }
79 unsigned getMinPrefetchStride(unsigned NumMemAccesses,
80 unsigned NumStridedMemAccesses,
81 unsigned NumPrefetches,
82 bool HasCall) const override;
83 bool enableWritePrefetching() const override { return true; }
84
85 unsigned getMaxInterleaveFactor(ElementCount VF) const override;
86
87 bool hasDivRemOp(Type *DataType, bool IsSigned) const override;
88 bool prefersVectorizedAddressing() const override { return false; }
89 bool LSRWithInstrQueries() const override { return true; }
91 getScalarizationOverhead(VectorType *Ty, const APInt &DemandedElts,
92 bool Insert, bool Extract,
94 bool ForPoisonSrc = true, ArrayRef<Value *> VL = {},
96 TTI::VectorInstrContext::None) const override;
97 bool supportsEfficientVectorElementLoadStore() const override { return true; }
98 bool enableInterleavedAccessVectorization() const override { return true; }
99
101 unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
105 const Instruction *CxtI = nullptr) const override;
106
108 unsigned Opcode, Type *InputTypeA, Type *InputTypeB, Type *AccumType,
110 TTI::PartialReductionExtendKind OpBExtend, std::optional<unsigned> BinOp,
112 std::optional<FastMathFlags> FMF) const override {
114 }
115
119 VectorType *SubTp, ArrayRef<const Value *> Args = {},
120 const Instruction *CxtI = nullptr) const override;
121 unsigned getVectorTruncCost(Type *SrcTy, Type *DstTy) const;
122 unsigned getVectorBitmaskConversionCost(Type *SrcTy, Type *DstTy) const;
123 unsigned getBoolVecToIntConversionCost(unsigned Opcode, Type *Dst,
124 const Instruction *I) const;
126 getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
128 const Instruction *I = nullptr) const override;
130 const Instruction *I = nullptr) const override;
132 unsigned Opcode, Type *ValTy, Type *CondTy, CmpInst::Predicate VecPred,
136 const Instruction *I = nullptr) const override;
140 unsigned Index, const Value *Op0, const Value *Op1,
142 TTI::VectorInstrContext::None) const override;
143 bool isFoldableLoad(const LoadInst *Ld,
144 const Instruction *&FoldedValue) const;
146 unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace,
149 const Instruction *I = nullptr) const override;
150
152 unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices,
153 Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind,
154 bool UseMaskForCond = false, bool UseMaskForGaps = false) const override;
155
157 getArithmeticReductionCost(unsigned Opcode, VectorType *Ty,
158 std::optional<FastMathFlags> FMF,
159 TTI::TargetCostKind CostKind) const override;
161 getMinMaxReductionCost(Intrinsic::ID IID, VectorType *Ty, FastMathFlags FMF,
162 TTI::TargetCostKind CostKind) const override;
163
165 getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
166 TTI::TargetCostKind CostKind) const override;
167
168 bool preferEpilogueVectorization(ElementCount Iters) const override {
169 return true;
170 }
171
172 bool shouldExpandReduction(const IntrinsicInst *II) const override;
173 /// @}
174};
175
176} // end namespace llvm
177
178#endif
This file provides a helper that implements much of the TTI interface in terms of the target-independ...
static cl::opt< OutputCostKind > CostKind("cost-kind", cl::desc("Target cost kind"), cl::init(OutputCostKind::RecipThroughput), cl::values(clEnumValN(OutputCostKind::RecipThroughput, "throughput", "Reciprocal throughput"), clEnumValN(OutputCostKind::Latency, "latency", "Instruction latency"), clEnumValN(OutputCostKind::CodeSize, "code-size", "Code size"), clEnumValN(OutputCostKind::SizeAndLatency, "size-latency", "Code size and latency"), clEnumValN(OutputCostKind::All, "all", "Print all cost kinds")))
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
uint64_t IntrinsicInst * II
This pass exposes codegen information to IR-level passes.
Class for arbitrary precision integers.
Definition APInt.h:78
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index, const Value *Op0, const Value *Op1, TTI::VectorInstrContext VIC=TTI::VectorInstrContext::None) const override
BasicTTIImplBase(const TargetMachine *TM, const DataLayout &DL)
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition InstrTypes.h:676
static InstructionCost getInvalid(CostType Val=0)
A wrapper class for inspecting calls to intrinsic functions.
Represents a single loop in the control flow graph.
Definition LoopInfo.h:40
The optimization diagnostic interface.
The main scalar evolution driver.
InstructionCost getScalarizationOverhead(VectorType *Ty, const APInt &DemandedElts, bool Insert, bool Extract, TTI::TargetCostKind CostKind, bool ForPoisonSrc=true, ArrayRef< Value * > VL={}, TTI::VectorInstrContext VIC=TTI::VectorInstrContext::None) const override
Estimate the overhead of scalarizing an instruction.
bool isFoldableLoad(const LoadInst *Ld, const Instruction *&FoldedValue) const
bool isLSRCostLess(const TargetTransformInfo::LSRCost &C1, const TargetTransformInfo::LSRCost &C2) const override
InstructionCost getMinMaxReductionCost(Intrinsic::ID IID, VectorType *Ty, FastMathFlags FMF, TTI::TargetCostKind CostKind) const override
Try to calculate op costs for min/max reduction operations.
bool enableInterleavedAccessVectorization() const override
InstructionCost getCFInstrCost(unsigned Opcode, TTI::TargetCostKind CostKind, const Instruction *I=nullptr) const override
InstructionCost getShuffleCost(TTI::ShuffleKind Kind, VectorType *DstTy, VectorType *SrcTy, ArrayRef< int > Mask, TTI::TargetCostKind CostKind, int Index, VectorType *SubTp, ArrayRef< const Value * > Args={}, const Instruction *CxtI=nullptr) const override
SystemZTTIImpl(const SystemZTargetMachine *TM, const Function &F)
bool enableWritePrefetching() const override
unsigned getNumberOfRegisters(unsigned ClassID) const override
bool LSRWithInstrQueries() const override
void getPeelingPreferences(Loop *L, ScalarEvolution &SE, TTI::PeelingPreferences &PP) const override
unsigned getMaxInterleaveFactor(ElementCount VF) const override
bool preferEpilogueVectorization(ElementCount Iters) const override
InstructionCost getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA, TTI::TargetCostKind CostKind) const override
Get intrinsic cost based on arguments.
unsigned getMinPrefetchStride(unsigned NumMemAccesses, unsigned NumStridedMemAccesses, unsigned NumPrefetches, bool HasCall) const override
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index, const Value *Op0, const Value *Op1, TTI::VectorInstrContext VIC=TTI::VectorInstrContext::None) const override
InstructionCost getArithmeticInstrCost(unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind, TTI::OperandValueInfo Op1Info={TTI::OK_AnyValue, TTI::OP_None}, TTI::OperandValueInfo Op2Info={TTI::OK_AnyValue, TTI::OP_None}, ArrayRef< const Value * > Args={}, const Instruction *CxtI=nullptr) const override
InstructionCost getPartialReductionCost(unsigned Opcode, Type *InputTypeA, Type *InputTypeB, Type *AccumType, ElementCount VF, TTI::PartialReductionExtendKind OpAExtend, TTI::PartialReductionExtendKind OpBExtend, std::optional< unsigned > BinOp, TTI::TargetCostKind CostKind, std::optional< FastMathFlags > FMF) const override
unsigned getPrefetchDistance() const override
InstructionCost getIntImmCostIntrin(Intrinsic::ID IID, unsigned Idx, const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind) const override
unsigned getVectorBitmaskConversionCost(Type *SrcTy, Type *DstTy) const
unsigned getBoolVecToIntConversionCost(unsigned Opcode, Type *Dst, const Instruction *I) const
InstructionCost getIntImmCostInst(unsigned Opcode, unsigned Idx, const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind, Instruction *Inst=nullptr) const override
bool shouldExpandReduction(const IntrinsicInst *II) const override
TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth) const override
InstructionCost getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef< unsigned > Indices, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, bool UseMaskForCond=false, bool UseMaskForGaps=false) const override
InstructionCost getArithmeticReductionCost(unsigned Opcode, VectorType *Ty, std::optional< FastMathFlags > FMF, TTI::TargetCostKind CostKind) const override
bool hasDivRemOp(Type *DataType, bool IsSigned) const override
unsigned getVectorTruncCost(Type *SrcTy, Type *DstTy) const
void getUnrollingPreferences(Loop *L, ScalarEvolution &SE, TTI::UnrollingPreferences &UP, OptimizationRemarkEmitter *ORE) const override
bool supportsEfficientVectorElementLoadStore() const override
unsigned adjustInliningThreshold(const CallBase *CB) const override
InstructionCost getMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, TTI::OperandValueInfo OpInfo={TTI::OK_AnyValue, TTI::OP_None}, const Instruction *I=nullptr) const override
InstructionCost getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy, CmpInst::Predicate VecPred, TTI::TargetCostKind CostKind, TTI::OperandValueInfo Op1Info={TTI::OK_AnyValue, TTI::OP_None}, TTI::OperandValueInfo Op2Info={TTI::OK_AnyValue, TTI::OP_None}, const Instruction *I=nullptr) const override
TypeSize getRegisterBitWidth(TargetTransformInfo::RegisterKind K) const override
InstructionCost getIntImmCost(const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind) const override
unsigned getCacheLineSize() const override
bool prefersVectorizedAddressing() const override
InstructionCost getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src, TTI::CastContextHint CCH, TTI::TargetCostKind CostKind, const Instruction *I=nullptr) const override
virtual const DataLayout & getDataLayout() const
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
VectorInstrContext
Represents a hint about the context in which an insert/extract is used.
@ None
The insert/extract is not used with a load/store.
TargetCostKind
The kind of cost model.
PopcntSupportKind
Flags indicating the kind of support for population count.
ShuffleKind
The various kinds of shuffle patterns for vector queries.
CastContextHint
Represents a hint about the context in which a cast is used.
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
Base class of all SIMD vector types.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
friend class Instruction
Iterator for Instructions in a `BasicBlock.
Definition BasicBlock.h:73
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr Value
Definition InstrProf.h:137
ArrayRef(const T &OneElt) -> ArrayRef< T >
Parameters that control the generic loop unrolling transformation.