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 public: 32 explicit SystemZTTIImpl(const SystemZTargetMachine *TM, const Function &F) 33 : BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)), 34 TLI(ST->getTargetLowering()) {} 35 36 /// \name Scalar TTI Implementations 37 /// @{ 38 39 unsigned getInliningThresholdMultiplier() { return 3; } 40 41 int getIntImmCost(const APInt &Imm, Type *Ty); 42 43 int getIntImmCostInst(unsigned Opcode, unsigned Idx, const APInt &Imm, Type *Ty); 44 int getIntImmCostIntrin(Intrinsic::ID IID, unsigned Idx, const APInt &Imm, 45 Type *Ty); 46 47 TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth); 48 49 void getUnrollingPreferences(Loop *L, ScalarEvolution &SE, 50 TTI::UnrollingPreferences &UP); 51 52 bool isLSRCostLess(TargetTransformInfo::LSRCost &C1, 53 TargetTransformInfo::LSRCost &C2); 54 /// @} 55 56 /// \name Vector TTI Implementations 57 /// @{ 58 59 unsigned getNumberOfRegisters(unsigned ClassID) const; 60 unsigned getRegisterBitWidth(bool Vector) const; 61 62 unsigned getCacheLineSize() const override { return 256; } 63 unsigned getPrefetchDistance() const override { return 4500; } 64 unsigned getMinPrefetchStride(unsigned NumMemAccesses, 65 unsigned NumStridedMemAccesses, 66 unsigned NumPrefetches, 67 bool HasCall) const override; 68 bool enableWritePrefetching() const override { return true; } 69 70 bool hasDivRemOp(Type *DataType, bool IsSigned); 71 bool prefersVectorizedAddressing() { return false; } 72 bool LSRWithInstrQueries() { return true; } 73 bool supportsEfficientVectorElementLoadStore() { return true; } 74 bool enableInterleavedAccessVectorization() { return true; } 75 76 int getArithmeticInstrCost( 77 unsigned Opcode, Type *Ty, 78 TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue, 79 TTI::OperandValueKind Opd2Info = TTI::OK_AnyValue, 80 TTI::OperandValueProperties Opd1PropInfo = TTI::OP_None, 81 TTI::OperandValueProperties Opd2PropInfo = TTI::OP_None, 82 ArrayRef<const Value *> Args = ArrayRef<const Value *>(), 83 const Instruction *CxtI = nullptr); 84 int getShuffleCost(TTI::ShuffleKind Kind, VectorType *Tp, int Index, 85 VectorType *SubTp); 86 unsigned getVectorTruncCost(Type *SrcTy, Type *DstTy); 87 unsigned getVectorBitmaskConversionCost(Type *SrcTy, Type *DstTy); 88 unsigned getBoolVecToIntConversionCost(unsigned Opcode, Type *Dst, 89 const Instruction *I); 90 int getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src, 91 const Instruction *I = nullptr); 92 int getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy, 93 const Instruction *I = nullptr); 94 int getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index); 95 bool isFoldableLoad(const LoadInst *Ld, const Instruction *&FoldedValue); 96 int getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment, 97 unsigned AddressSpace, const Instruction *I = nullptr); 98 99 int getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy, 100 unsigned Factor, 101 ArrayRef<unsigned> Indices, 102 unsigned Alignment, 103 unsigned AddressSpace, 104 bool UseMaskForCond = false, 105 bool UseMaskForGaps = false); 106 107 int getIntrinsicInstrCost(Intrinsic::ID ID, Type *RetTy, 108 ArrayRef<Value *> Args, FastMathFlags FMF, 109 unsigned VF = 1, const Instruction *I = nullptr); 110 int getIntrinsicInstrCost(Intrinsic::ID ID, Type *RetTy, ArrayRef<Type *> Tys, 111 FastMathFlags FMF, 112 unsigned ScalarizationCostPassed = UINT_MAX, 113 const Instruction *I = nullptr); 114 /// @} 115 }; 116 117 } // end namespace llvm 118 119 #endif 120