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" |
13 | #include "llvm/Analysis/TargetTransformInfo.h" |
14 | #include "llvm/CodeGen/BasicTTIImpl.h" |
15 | |
16 | namespace llvm { |
17 | |
18 | class SystemZTTIImpl final : public BasicTTIImplBase<SystemZTTIImpl> { |
19 | typedef BasicTTIImplBase<SystemZTTIImpl> BaseT; |
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(Bitwidth: 128) && ST->hasVector(); |
33 | } |
34 | |
35 | public: |
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 | |
45 | InstructionCost getIntImmCost(const APInt &Imm, Type *Ty, |
46 | TTI::TargetCostKind CostKind) const override; |
47 | |
48 | InstructionCost getIntImmCostInst(unsigned Opcode, unsigned Idx, |
49 | const APInt &Imm, Type *Ty, |
50 | TTI::TargetCostKind CostKind, |
51 | Instruction *Inst = nullptr) const override; |
52 | InstructionCost |
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 | |
58 | void (Loop *L, ScalarEvolution &SE, |
59 | TTI::UnrollingPreferences &UP, |
60 | OptimizationRemarkEmitter *ORE) const override; |
61 | |
62 | void getPeelingPreferences(Loop *L, ScalarEvolution &SE, |
63 | TTI::PeelingPreferences &PP) const override; |
64 | |
65 | bool isLSRCostLess(const TargetTransformInfo::LSRCost &C1, |
66 | const TargetTransformInfo::LSRCost &C2) const override; |
67 | |
68 | bool areInlineCompatible(const Function *Caller, |
69 | const Function *Callee) const override; |
70 | |
71 | /// @} |
72 | |
73 | /// \name Vector TTI Implementations |
74 | /// @{ |
75 | |
76 | unsigned getNumberOfRegisters(unsigned ClassID) const override; |
77 | TypeSize |
78 | getRegisterBitWidth(TargetTransformInfo::RegisterKind K) const override; |
79 | |
80 | unsigned getCacheLineSize() const override { return 256; } |
81 | unsigned getPrefetchDistance() const override { return 4500; } |
82 | unsigned getMinPrefetchStride(unsigned NumMemAccesses, |
83 | unsigned NumStridedMemAccesses, |
84 | unsigned NumPrefetches, |
85 | bool HasCall) const override; |
86 | bool enableWritePrefetching() const override { return true; } |
87 | |
88 | bool hasDivRemOp(Type *DataType, bool IsSigned) const override; |
89 | bool prefersVectorizedAddressing() const override { return false; } |
90 | bool LSRWithInstrQueries() const override { return true; } |
91 | InstructionCost getScalarizationOverhead( |
92 | VectorType *Ty, const APInt &DemandedElts, bool Insert, bool , |
93 | TTI::TargetCostKind CostKind, bool ForPoisonSrc = true, |
94 | ArrayRef<Value *> VL = {}) const override; |
95 | bool supportsEfficientVectorElementLoadStore() const override { return true; } |
96 | bool enableInterleavedAccessVectorization() const override { return true; } |
97 | |
98 | InstructionCost getArithmeticInstrCost( |
99 | unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind, |
100 | TTI::OperandValueInfo Op1Info = {.Kind: TTI::OK_AnyValue, .Properties: TTI::OP_None}, |
101 | TTI::OperandValueInfo Op2Info = {.Kind: TTI::OK_AnyValue, .Properties: TTI::OP_None}, |
102 | ArrayRef<const Value *> Args = {}, |
103 | const Instruction *CxtI = nullptr) const override; |
104 | InstructionCost |
105 | getShuffleCost(TTI::ShuffleKind Kind, VectorType *DstTy, VectorType *SrcTy, |
106 | ArrayRef<int> Mask, TTI::TargetCostKind CostKind, int Index, |
107 | VectorType *SubTp, ArrayRef<const Value *> Args = {}, |
108 | const Instruction *CxtI = nullptr) const override; |
109 | unsigned getVectorTruncCost(Type *SrcTy, Type *DstTy) const; |
110 | unsigned getVectorBitmaskConversionCost(Type *SrcTy, Type *DstTy) const; |
111 | unsigned getBoolVecToIntConversionCost(unsigned Opcode, Type *Dst, |
112 | const Instruction *I) const; |
113 | InstructionCost |
114 | getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src, |
115 | TTI::CastContextHint CCH, TTI::TargetCostKind CostKind, |
116 | const Instruction *I = nullptr) const override; |
117 | InstructionCost getCmpSelInstrCost( |
118 | unsigned Opcode, Type *ValTy, Type *CondTy, CmpInst::Predicate VecPred, |
119 | TTI::TargetCostKind CostKind, |
120 | TTI::OperandValueInfo Op1Info = {.Kind: TTI::OK_AnyValue, .Properties: TTI::OP_None}, |
121 | TTI::OperandValueInfo Op2Info = {.Kind: TTI::OK_AnyValue, .Properties: TTI::OP_None}, |
122 | const Instruction *I = nullptr) const override; |
123 | using BaseT::getVectorInstrCost; |
124 | InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val, |
125 | TTI::TargetCostKind CostKind, |
126 | unsigned Index, const Value *Op0, |
127 | const Value *Op1) const override; |
128 | bool isFoldableLoad(const LoadInst *Ld, |
129 | const Instruction *&FoldedValue) const; |
130 | InstructionCost getMemoryOpCost( |
131 | unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace, |
132 | TTI::TargetCostKind CostKind, |
133 | TTI::OperandValueInfo OpInfo = {.Kind: TTI::OK_AnyValue, .Properties: TTI::OP_None}, |
134 | const Instruction *I = nullptr) const override; |
135 | |
136 | InstructionCost getInterleavedMemoryOpCost( |
137 | unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices, |
138 | Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, |
139 | bool UseMaskForCond = false, bool UseMaskForGaps = false) const override; |
140 | |
141 | InstructionCost |
142 | getArithmeticReductionCost(unsigned Opcode, VectorType *Ty, |
143 | std::optional<FastMathFlags> FMF, |
144 | TTI::TargetCostKind CostKind) const override; |
145 | InstructionCost |
146 | getMinMaxReductionCost(Intrinsic::ID IID, VectorType *Ty, FastMathFlags FMF, |
147 | TTI::TargetCostKind CostKind) const override; |
148 | |
149 | InstructionCost |
150 | getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA, |
151 | TTI::TargetCostKind CostKind) const override; |
152 | |
153 | bool shouldExpandReduction(const IntrinsicInst *II) const override; |
154 | /// @} |
155 | }; |
156 | |
157 | } // end namespace llvm |
158 | |
159 | #endif |
160 | |