LLVM 22.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> {
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 bool hasDivRemOp(Type *DataType, bool IsSigned) const override;
86 bool prefersVectorizedAddressing() const override { return false; }
87 bool LSRWithInstrQueries() const override { return true; }
89 VectorType *Ty, const APInt &DemandedElts, bool Insert, bool Extract,
90 TTI::TargetCostKind CostKind, bool ForPoisonSrc = true,
91 ArrayRef<Value *> VL = {}) const override;
92 bool supportsEfficientVectorElementLoadStore() const override { return true; }
93 bool enableInterleavedAccessVectorization() const override { return true; }
94
96 unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
98 TTI::OperandValueInfo Op2Info = {TTI::OK_AnyValue, TTI::OP_None},
99 ArrayRef<const Value *> Args = {},
100 const Instruction *CxtI = nullptr) const override;
103 ArrayRef<int> Mask, TTI::TargetCostKind CostKind, int Index,
104 VectorType *SubTp, ArrayRef<const Value *> Args = {},
105 const Instruction *CxtI = nullptr) const override;
106 unsigned getVectorTruncCost(Type *SrcTy, Type *DstTy) const;
107 unsigned getVectorBitmaskConversionCost(Type *SrcTy, Type *DstTy) const;
108 unsigned getBoolVecToIntConversionCost(unsigned Opcode, Type *Dst,
109 const Instruction *I) const;
111 getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
113 const Instruction *I = nullptr) const override;
115 unsigned Opcode, Type *ValTy, Type *CondTy, CmpInst::Predicate VecPred,
117 TTI::OperandValueInfo Op1Info = {TTI::OK_AnyValue, TTI::OP_None},
118 TTI::OperandValueInfo Op2Info = {TTI::OK_AnyValue, TTI::OP_None},
119 const Instruction *I = nullptr) const override;
121 InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val,
123 unsigned Index, const Value *Op0,
124 const Value *Op1) const override;
125 bool isFoldableLoad(const LoadInst *Ld,
126 const Instruction *&FoldedValue) const;
128 unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace,
130 TTI::OperandValueInfo OpInfo = {TTI::OK_AnyValue, TTI::OP_None},
131 const Instruction *I = nullptr) const override;
132
134 unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices,
135 Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind,
136 bool UseMaskForCond = false, bool UseMaskForGaps = false) const override;
137
139 getArithmeticReductionCost(unsigned Opcode, VectorType *Ty,
140 std::optional<FastMathFlags> FMF,
141 TTI::TargetCostKind CostKind) const override;
143 getMinMaxReductionCost(Intrinsic::ID IID, VectorType *Ty, FastMathFlags FMF,
144 TTI::TargetCostKind CostKind) const override;
145
147 getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
148 TTI::TargetCostKind CostKind) const override;
149
150 bool shouldExpandReduction(const IntrinsicInst *II) const override;
151 /// @}
152};
153
154} // end namespace llvm
155
156#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")))
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
uint32_t Index
#define F(x, y, z)
Definition: MD5.cpp:55
#define I(x, y, z)
Definition: MD5.cpp:58
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:41
Base class which can be used to help build a TTI implementation.
Definition: BasicTTIImpl.h:82
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index, const Value *Op0, const Value *Op1) const override
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition: InstrTypes.h:1116
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition: InstrTypes.h:678
Represents a single loop in the control flow graph.
Definition: LoopInfo.h:40
The optimization diagnostic interface.
The main scalar evolution driver.
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
InstructionCost getScalarizationOverhead(VectorType *Ty, const APInt &DemandedElts, bool Insert, bool Extract, TTI::TargetCostKind CostKind, bool ForPoisonSrc=true, ArrayRef< Value * > VL={}) const override
bool enableInterleavedAccessVectorization() 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
InstructionCost getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA, TTI::TargetCostKind CostKind) const override
unsigned getMinPrefetchStride(unsigned NumMemAccesses, unsigned NumStridedMemAccesses, unsigned NumPrefetches, bool HasCall) 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
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 getVectorInstrCost(unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index, const Value *Op0, const Value *Op1) const override
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.
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:45
bool isIntegerTy() const
True if this is an instance of IntegerType.
Definition: Type.h:240
Base class of all SIMD vector types.
Definition: DerivedTypes.h:430
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
Parameters that control the generic loop unrolling transformation.