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, TTI::TargetCostKind CostKind); 42 43 int getIntImmCostInst(unsigned Opcode, unsigned Idx, const APInt &Imm, 44 Type *Ty, TTI::TargetCostKind CostKind, 45 Instruction *Inst = nullptr); 46 int getIntImmCostIntrin(Intrinsic::ID IID, unsigned Idx, const APInt &Imm, 47 Type *Ty, TTI::TargetCostKind CostKind); 48 49 TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth); 50 51 void getUnrollingPreferences(Loop *L, ScalarEvolution &SE, 52 TTI::UnrollingPreferences &UP); 53 54 void getPeelingPreferences(Loop *L, ScalarEvolution &SE, 55 TTI::PeelingPreferences &PP); 56 57 bool isLSRCostLess(TargetTransformInfo::LSRCost &C1, 58 TargetTransformInfo::LSRCost &C2); 59 /// @} 60 61 /// \name Vector TTI Implementations 62 /// @{ 63 64 unsigned getNumberOfRegisters(unsigned ClassID) const; 65 TypeSize getRegisterBitWidth(TargetTransformInfo::RegisterKind K) const; 66 67 unsigned getCacheLineSize() const override { return 256; } 68 unsigned getPrefetchDistance() const override { return 4500; } 69 unsigned getMinPrefetchStride(unsigned NumMemAccesses, 70 unsigned NumStridedMemAccesses, 71 unsigned NumPrefetches, 72 bool HasCall) const override; 73 bool enableWritePrefetching() const override { return true; } 74 75 bool hasDivRemOp(Type *DataType, bool IsSigned); 76 bool prefersVectorizedAddressing() { return false; } 77 bool LSRWithInstrQueries() { return true; } 78 bool supportsEfficientVectorElementLoadStore() { return true; } 79 bool enableInterleavedAccessVectorization() { return true; } 80 81 InstructionCost getArithmeticInstrCost( 82 unsigned Opcode, Type *Ty, 83 TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput, 84 TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue, 85 TTI::OperandValueKind Opd2Info = TTI::OK_AnyValue, 86 TTI::OperandValueProperties Opd1PropInfo = TTI::OP_None, 87 TTI::OperandValueProperties Opd2PropInfo = TTI::OP_None, 88 ArrayRef<const Value *> Args = ArrayRef<const Value *>(), 89 const Instruction *CxtI = nullptr); 90 InstructionCost getShuffleCost(TTI::ShuffleKind Kind, VectorType *Tp, 91 ArrayRef<int> Mask, int Index, 92 VectorType *SubTp); 93 unsigned getVectorTruncCost(Type *SrcTy, Type *DstTy); 94 unsigned getVectorBitmaskConversionCost(Type *SrcTy, Type *DstTy); 95 unsigned getBoolVecToIntConversionCost(unsigned Opcode, Type *Dst, 96 const Instruction *I); 97 InstructionCost getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src, 98 TTI::CastContextHint CCH, 99 TTI::TargetCostKind CostKind, 100 const Instruction *I = nullptr); 101 InstructionCost getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy, 102 CmpInst::Predicate VecPred, 103 TTI::TargetCostKind CostKind, 104 const Instruction *I = nullptr); 105 InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val, 106 unsigned Index); 107 bool isFoldableLoad(const LoadInst *Ld, const Instruction *&FoldedValue); 108 InstructionCost getMemoryOpCost(unsigned Opcode, Type *Src, 109 MaybeAlign Alignment, unsigned AddressSpace, 110 TTI::TargetCostKind CostKind, 111 const Instruction *I = nullptr); 112 113 InstructionCost getInterleavedMemoryOpCost( 114 unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices, 115 Align Alignment, unsigned AddressSpace, 116 TTI::TargetCostKind CostKind = TTI::TCK_SizeAndLatency, 117 bool UseMaskForCond = false, bool UseMaskForGaps = false); 118 119 InstructionCost getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA, 120 TTI::TargetCostKind CostKind); 121 /// @} 122 }; 123 124 } // end namespace llvm 125 126 #endif 127