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