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 2000; } 64 unsigned getMinPrefetchStride() const override { return 2048; } 65 66 bool hasDivRemOp(Type *DataType, bool IsSigned); 67 bool prefersVectorizedAddressing() { return false; } 68 bool LSRWithInstrQueries() { return true; } 69 bool supportsEfficientVectorElementLoadStore() { return true; } 70 bool enableInterleavedAccessVectorization() { return true; } 71 72 int getArithmeticInstrCost( 73 unsigned Opcode, Type *Ty, 74 TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue, 75 TTI::OperandValueKind Opd2Info = TTI::OK_AnyValue, 76 TTI::OperandValueProperties Opd1PropInfo = TTI::OP_None, 77 TTI::OperandValueProperties Opd2PropInfo = TTI::OP_None, 78 ArrayRef<const Value *> Args = ArrayRef<const Value *>(), 79 const Instruction *CxtI = nullptr); 80 int getShuffleCost(TTI::ShuffleKind Kind, Type *Tp, int Index, Type *SubTp); 81 unsigned getVectorTruncCost(Type *SrcTy, Type *DstTy); 82 unsigned getVectorBitmaskConversionCost(Type *SrcTy, Type *DstTy); 83 unsigned getBoolVecToIntConversionCost(unsigned Opcode, Type *Dst, 84 const Instruction *I); 85 int getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src, 86 const Instruction *I = nullptr); 87 int getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy, 88 const Instruction *I = nullptr); 89 int getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index); 90 bool isFoldableLoad(const LoadInst *Ld, const Instruction *&FoldedValue); 91 int getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment, 92 unsigned AddressSpace, const Instruction *I = nullptr); 93 94 int getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy, 95 unsigned Factor, 96 ArrayRef<unsigned> Indices, 97 unsigned Alignment, 98 unsigned AddressSpace, 99 bool UseMaskForCond = false, 100 bool UseMaskForGaps = false); 101 102 int getIntrinsicInstrCost(Intrinsic::ID ID, Type *RetTy, 103 ArrayRef<Value *> Args, FastMathFlags FMF, 104 unsigned VF = 1); 105 int getIntrinsicInstrCost(Intrinsic::ID ID, Type *RetTy, 106 ArrayRef<Type *> Tys, FastMathFlags FMF, 107 unsigned ScalarizationCostPassed = UINT_MAX); 108 /// @} 109 }; 110 111 } // end namespace llvm 112 113 #endif 114