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 : 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) { return Ty->isIntegerTy(128) && ST->hasVector(); } 32 33 public: 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 43 InstructionCost getIntImmCost(const APInt &Imm, Type *Ty, 44 TTI::TargetCostKind CostKind); 45 46 InstructionCost getIntImmCostInst(unsigned Opcode, unsigned Idx, 47 const APInt &Imm, Type *Ty, 48 TTI::TargetCostKind CostKind, 49 Instruction *Inst = nullptr); 50 InstructionCost getIntImmCostIntrin(Intrinsic::ID IID, unsigned Idx, 51 const APInt &Imm, Type *Ty, 52 TTI::TargetCostKind CostKind); 53 54 TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth); 55 56 void getUnrollingPreferences(Loop *L, ScalarEvolution &SE, 57 TTI::UnrollingPreferences &UP, 58 OptimizationRemarkEmitter *ORE); 59 60 void getPeelingPreferences(Loop *L, ScalarEvolution &SE, 61 TTI::PeelingPreferences &PP); 62 63 bool isLSRCostLess(const TargetTransformInfo::LSRCost &C1, 64 const TargetTransformInfo::LSRCost &C2); 65 /// @} 66 67 /// \name Vector TTI Implementations 68 /// @{ 69 70 unsigned getNumberOfRegisters(unsigned ClassID) const; 71 TypeSize getRegisterBitWidth(TargetTransformInfo::RegisterKind K) 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; } 84 InstructionCost getScalarizationOverhead(VectorType *Ty, 85 const APInt &DemandedElts, 86 bool Insert, bool Extract, 87 TTI::TargetCostKind CostKind, 88 ArrayRef<Value *> VL = {}); 89 bool supportsEfficientVectorElementLoadStore() { return true; } 90 bool enableInterleavedAccessVectorization() { return true; } 91 92 InstructionCost getArithmeticInstrCost( 93 unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind, 94 TTI::OperandValueInfo Op1Info = {TTI::OK_AnyValue, TTI::OP_None}, 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, 99 TTI::TargetCostKind CostKind, int Index, 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, 108 TTI::CastContextHint CCH, 109 TTI::TargetCostKind CostKind, 110 const Instruction *I = nullptr); 111 InstructionCost getCmpSelInstrCost( 112 unsigned Opcode, Type *ValTy, Type *CondTy, CmpInst::Predicate VecPred, 113 TTI::TargetCostKind CostKind, 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); 117 using BaseT::getVectorInstrCost; 118 InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val, 119 TTI::TargetCostKind CostKind, 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, 124 unsigned AddressSpace, TTI::TargetCostKind CostKind, 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, 135 TTI::TargetCostKind CostKind); 136 InstructionCost getMinMaxReductionCost(Intrinsic::ID IID, VectorType *Ty, 137 FastMathFlags FMF, 138 TTI::TargetCostKind CostKind); 139 140 InstructionCost getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA, 141 TTI::TargetCostKind CostKind); 142 143 bool shouldExpandReduction(const IntrinsicInst *II) const; 144 /// @} 145 }; 146 147 } // end namespace llvm 148 149 #endif 150