LLVM 20.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 : 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) { return Ty->isIntegerTy(128) && ST->hasVector(); }
32
33public:
34 explicit SystemZTTIImpl(const SystemZTargetMachine *TM, const Function &F)
35 : BaseT(TM, F.getDataLayout()), ST(TM->getSubtargetImpl(F)),
36 TLI(ST->getTargetLowering()) {}
37
38 /// \name Scalar TTI Implementations
39 /// @{
40
41 unsigned adjustInliningThreshold(const CallBase *CB) const;
42
45
46 InstructionCost getIntImmCostInst(unsigned Opcode, unsigned Idx,
47 const APInt &Imm, Type *Ty,
49 Instruction *Inst = nullptr);
51 const APInt &Imm, Type *Ty,
53
55
59
62
65 /// @}
66
67 /// \name Vector TTI Implementations
68 /// @{
69
70 unsigned getNumberOfRegisters(unsigned ClassID) const;
72
73 unsigned getCacheLineSize() const override { return 256; }
74 unsigned getPrefetchDistance() const override { return 4500; }
75 unsigned getMinPrefetchStride(unsigned NumMemAccesses,
76 unsigned NumStridedMemAccesses,
77 unsigned NumPrefetches,
78 bool HasCall) const override;
79 bool enableWritePrefetching() const override { return true; }
80
81 bool hasDivRemOp(Type *DataType, bool IsSigned);
82 bool prefersVectorizedAddressing() { return false; }
83 bool LSRWithInstrQueries() { return true; }
85 const APInt &DemandedElts,
86 bool Insert, bool Extract,
88 ArrayRef<Value *> VL = {});
91
93 unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
95 TTI::OperandValueInfo Op2Info = {TTI::OK_AnyValue, TTI::OP_None},
96 ArrayRef<const Value *> Args = {}, const Instruction *CxtI = nullptr);
97 InstructionCost getShuffleCost(TTI::ShuffleKind Kind, VectorType *Tp,
98 ArrayRef<int> Mask,
100 VectorType *SubTp,
101 ArrayRef<const Value *> Args = {},
102 const Instruction *CxtI = nullptr);
103 unsigned getVectorTruncCost(Type *SrcTy, Type *DstTy);
104 unsigned getVectorBitmaskConversionCost(Type *SrcTy, Type *DstTy);
105 unsigned getBoolVecToIntConversionCost(unsigned Opcode, Type *Dst,
106 const Instruction *I);
107 InstructionCost getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
110 const Instruction *I = nullptr);
111 InstructionCost getCmpSelInstrCost(
112 unsigned Opcode, Type *ValTy, Type *CondTy, CmpInst::Predicate VecPred,
114 TTI::OperandValueInfo Op1Info = {TTI::OK_AnyValue, TTI::OP_None},
115 TTI::OperandValueInfo Op2Info = {TTI::OK_AnyValue, TTI::OP_None},
116 const Instruction *I = nullptr);
118 InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val,
120 unsigned Index, Value *Op0, Value *Op1);
121 bool isFoldableLoad(const LoadInst *Ld, const Instruction *&FoldedValue);
122 InstructionCost
123 getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment,
125 TTI::OperandValueInfo OpInfo = {TTI::OK_AnyValue, TTI::OP_None},
126 const Instruction *I = nullptr);
127
128 InstructionCost getInterleavedMemoryOpCost(
129 unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices,
130 Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind,
131 bool UseMaskForCond = false, bool UseMaskForGaps = false);
132
133 InstructionCost getArithmeticReductionCost(unsigned Opcode, VectorType *Ty,
134 std::optional<FastMathFlags> FMF,
136 InstructionCost getMinMaxReductionCost(Intrinsic::ID IID, VectorType *Ty,
137 FastMathFlags FMF,
139
140 InstructionCost getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
142
143 bool shouldExpandReduction(const IntrinsicInst *II) const;
144 /// @}
145};
146
147} // end namespace llvm
148
149#endif
This file provides a helper that implements much of the TTI interface in terms of the target-independ...
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")))
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:80
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index, Value *Op0, Value *Op1)
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition: InstrTypes.h:1120
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition: InstrTypes.h:673
Represents a single loop in the control flow graph.
Definition: LoopInfo.h:39
The optimization diagnostic interface.
The main scalar evolution driver.
void getPeelingPreferences(Loop *L, ScalarEvolution &SE, TTI::PeelingPreferences &PP)
InstructionCost getIntImmCost(const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind)
InstructionCost getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef< unsigned > Indices, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, bool UseMaskForCond=false, bool UseMaskForGaps=false)
bool shouldExpandReduction(const IntrinsicInst *II) const
SystemZTTIImpl(const SystemZTargetMachine *TM, const Function &F)
bool enableWritePrefetching() const override
unsigned getNumberOfRegisters(unsigned ClassID) const
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)
TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth)
unsigned getBoolVecToIntConversionCost(unsigned Opcode, Type *Dst, const Instruction *I)
unsigned getMinPrefetchStride(unsigned NumMemAccesses, unsigned NumStridedMemAccesses, unsigned NumPrefetches, bool HasCall) const override
unsigned adjustInliningThreshold(const CallBase *CB) const
unsigned getVectorTruncCost(Type *SrcTy, Type *DstTy)
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index, Value *Op0, Value *Op1)
unsigned getPrefetchDistance() const override
bool isFoldableLoad(const LoadInst *Ld, const Instruction *&FoldedValue)
InstructionCost getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA, TTI::TargetCostKind CostKind)
InstructionCost getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, TTI::OperandValueInfo OpInfo={TTI::OK_AnyValue, TTI::OP_None}, const Instruction *I=nullptr)
void getUnrollingPreferences(Loop *L, ScalarEvolution &SE, TTI::UnrollingPreferences &UP, OptimizationRemarkEmitter *ORE)
bool isLSRCostLess(const TargetTransformInfo::LSRCost &C1, const TargetTransformInfo::LSRCost &C2)
InstructionCost getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src, TTI::CastContextHint CCH, TTI::TargetCostKind CostKind, const Instruction *I=nullptr)
InstructionCost getScalarizationOverhead(VectorType *Ty, const APInt &DemandedElts, bool Insert, bool Extract, TTI::TargetCostKind CostKind, ArrayRef< Value * > VL={})
unsigned getVectorBitmaskConversionCost(Type *SrcTy, Type *DstTy)
InstructionCost getIntImmCostInst(unsigned Opcode, unsigned Idx, const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind, Instruction *Inst=nullptr)
InstructionCost getMinMaxReductionCost(Intrinsic::ID IID, VectorType *Ty, FastMathFlags FMF, TTI::TargetCostKind CostKind)
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)
InstructionCost getArithmeticReductionCost(unsigned Opcode, VectorType *Ty, std::optional< FastMathFlags > FMF, TTI::TargetCostKind CostKind)
TypeSize getRegisterBitWidth(TargetTransformInfo::RegisterKind K) const
InstructionCost getIntImmCostIntrin(Intrinsic::ID IID, unsigned Idx, const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind)
unsigned getCacheLineSize() const override
InstructionCost getShuffleCost(TTI::ShuffleKind Kind, VectorType *Tp, ArrayRef< int > Mask, TTI::TargetCostKind CostKind, int Index, VectorType *SubTp, ArrayRef< const Value * > Args={}, const Instruction *CxtI=nullptr)
bool hasDivRemOp(Type *DataType, bool IsSigned)
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:237
Base class of all SIMD vector types.
Definition: DerivedTypes.h:427
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.