109467b48Spatrick //===-- SystemZTargetTransformInfo.h - SystemZ-specific TTI ---------------===// 209467b48Spatrick // 309467b48Spatrick // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 409467b48Spatrick // See https://llvm.org/LICENSE.txt for license information. 509467b48Spatrick // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 609467b48Spatrick // 709467b48Spatrick //===----------------------------------------------------------------------===// 809467b48Spatrick 909467b48Spatrick #ifndef LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZTARGETTRANSFORMINFO_H 1009467b48Spatrick #define LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZTARGETTRANSFORMINFO_H 1109467b48Spatrick 1209467b48Spatrick #include "SystemZTargetMachine.h" 1309467b48Spatrick #include "llvm/Analysis/TargetTransformInfo.h" 1409467b48Spatrick #include "llvm/CodeGen/BasicTTIImpl.h" 1509467b48Spatrick 1609467b48Spatrick namespace llvm { 1709467b48Spatrick 1809467b48Spatrick class SystemZTTIImpl : public BasicTTIImplBase<SystemZTTIImpl> { 1909467b48Spatrick typedef BasicTTIImplBase<SystemZTTIImpl> BaseT; 2009467b48Spatrick typedef TargetTransformInfo TTI; 2109467b48Spatrick friend BaseT; 2209467b48Spatrick 2309467b48Spatrick const SystemZSubtarget *ST; 2409467b48Spatrick const SystemZTargetLowering *TLI; 2509467b48Spatrick getST()2609467b48Spatrick const SystemZSubtarget *getST() const { return ST; } getTLI()2709467b48Spatrick const SystemZTargetLowering *getTLI() const { return TLI; } 2809467b48Spatrick 2909467b48Spatrick unsigned const LIBCALL_COST = 30; 3009467b48Spatrick 3109467b48Spatrick public: SystemZTTIImpl(const SystemZTargetMachine * TM,const Function & F)3209467b48Spatrick explicit SystemZTTIImpl(const SystemZTargetMachine *TM, const Function &F) 3309467b48Spatrick : BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)), 3409467b48Spatrick TLI(ST->getTargetLowering()) {} 3509467b48Spatrick 3609467b48Spatrick /// \name Scalar TTI Implementations 3709467b48Spatrick /// @{ 3809467b48Spatrick getInliningThresholdMultiplier()3909467b48Spatrick unsigned getInliningThresholdMultiplier() { return 3; } 40*d415bd75Srobert unsigned adjustInliningThreshold(const CallBase *CB) const; 4109467b48Spatrick 4273471bf0Spatrick InstructionCost getIntImmCost(const APInt &Imm, Type *Ty, 4373471bf0Spatrick TTI::TargetCostKind CostKind); 4409467b48Spatrick 4573471bf0Spatrick InstructionCost getIntImmCostInst(unsigned Opcode, unsigned Idx, 4673471bf0Spatrick const APInt &Imm, Type *Ty, 4773471bf0Spatrick TTI::TargetCostKind CostKind, 4873471bf0Spatrick Instruction *Inst = nullptr); 4973471bf0Spatrick InstructionCost getIntImmCostIntrin(Intrinsic::ID IID, unsigned Idx, 5073471bf0Spatrick const APInt &Imm, Type *Ty, 5173471bf0Spatrick TTI::TargetCostKind CostKind); 5209467b48Spatrick 5309467b48Spatrick TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth); 5409467b48Spatrick 5509467b48Spatrick void getUnrollingPreferences(Loop *L, ScalarEvolution &SE, 56*d415bd75Srobert TTI::UnrollingPreferences &UP, 57*d415bd75Srobert OptimizationRemarkEmitter *ORE); 5809467b48Spatrick 59097a140dSpatrick void getPeelingPreferences(Loop *L, ScalarEvolution &SE, 60097a140dSpatrick TTI::PeelingPreferences &PP); 61097a140dSpatrick 62*d415bd75Srobert bool isLSRCostLess(const TargetTransformInfo::LSRCost &C1, 63*d415bd75Srobert const TargetTransformInfo::LSRCost &C2); 6409467b48Spatrick /// @} 6509467b48Spatrick 6609467b48Spatrick /// \name Vector TTI Implementations 6709467b48Spatrick /// @{ 6809467b48Spatrick 6909467b48Spatrick unsigned getNumberOfRegisters(unsigned ClassID) const; 7073471bf0Spatrick TypeSize getRegisterBitWidth(TargetTransformInfo::RegisterKind K) const; 7109467b48Spatrick getCacheLineSize()7209467b48Spatrick unsigned getCacheLineSize() const override { return 256; } getPrefetchDistance()73097a140dSpatrick unsigned getPrefetchDistance() const override { return 4500; } 74097a140dSpatrick unsigned getMinPrefetchStride(unsigned NumMemAccesses, 75097a140dSpatrick unsigned NumStridedMemAccesses, 76097a140dSpatrick unsigned NumPrefetches, 77097a140dSpatrick bool HasCall) const override; enableWritePrefetching()78097a140dSpatrick bool enableWritePrefetching() const override { return true; } 7909467b48Spatrick 8009467b48Spatrick bool hasDivRemOp(Type *DataType, bool IsSigned); prefersVectorizedAddressing()8109467b48Spatrick bool prefersVectorizedAddressing() { return false; } LSRWithInstrQueries()8209467b48Spatrick bool LSRWithInstrQueries() { return true; } supportsEfficientVectorElementLoadStore()8309467b48Spatrick bool supportsEfficientVectorElementLoadStore() { return true; } enableInterleavedAccessVectorization()8409467b48Spatrick bool enableInterleavedAccessVectorization() { return true; } 8509467b48Spatrick 8673471bf0Spatrick InstructionCost getArithmeticInstrCost( 87*d415bd75Srobert unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind, 88*d415bd75Srobert TTI::OperandValueInfo Op1Info = {TTI::OK_AnyValue, TTI::OP_None}, 89*d415bd75Srobert TTI::OperandValueInfo Op2Info = {TTI::OK_AnyValue, TTI::OP_None}, 9009467b48Spatrick ArrayRef<const Value *> Args = ArrayRef<const Value *>(), 9109467b48Spatrick const Instruction *CxtI = nullptr); 9273471bf0Spatrick InstructionCost getShuffleCost(TTI::ShuffleKind Kind, VectorType *Tp, 93*d415bd75Srobert ArrayRef<int> Mask, 94*d415bd75Srobert TTI::TargetCostKind CostKind, int Index, 95*d415bd75Srobert VectorType *SubTp, 96*d415bd75Srobert ArrayRef<const Value *> Args = std::nullopt); 9709467b48Spatrick unsigned getVectorTruncCost(Type *SrcTy, Type *DstTy); 9809467b48Spatrick unsigned getVectorBitmaskConversionCost(Type *SrcTy, Type *DstTy); 9909467b48Spatrick unsigned getBoolVecToIntConversionCost(unsigned Opcode, Type *Dst, 10009467b48Spatrick const Instruction *I); 10173471bf0Spatrick InstructionCost getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src, 10273471bf0Spatrick TTI::CastContextHint CCH, 103097a140dSpatrick TTI::TargetCostKind CostKind, 10409467b48Spatrick const Instruction *I = nullptr); 10573471bf0Spatrick InstructionCost getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy, 10673471bf0Spatrick CmpInst::Predicate VecPred, 107097a140dSpatrick TTI::TargetCostKind CostKind, 10809467b48Spatrick const Instruction *I = nullptr); 109*d415bd75Srobert using BaseT::getVectorInstrCost; 11073471bf0Spatrick InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val, 11173471bf0Spatrick TTI::TargetCostKind CostKind, 112*d415bd75Srobert unsigned Index, Value *Op0, Value *Op1); 113*d415bd75Srobert bool isFoldableLoad(const LoadInst *Ld, const Instruction *&FoldedValue); 114*d415bd75Srobert InstructionCost 115*d415bd75Srobert getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment, 116*d415bd75Srobert unsigned AddressSpace, TTI::TargetCostKind CostKind, 117*d415bd75Srobert TTI::OperandValueInfo OpInfo = {TTI::OK_AnyValue, TTI::OP_None}, 118097a140dSpatrick const Instruction *I = nullptr); 11909467b48Spatrick 12073471bf0Spatrick InstructionCost getInterleavedMemoryOpCost( 121097a140dSpatrick unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices, 122*d415bd75Srobert Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, 123097a140dSpatrick bool UseMaskForCond = false, bool UseMaskForGaps = false); 12409467b48Spatrick 12573471bf0Spatrick InstructionCost getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA, 126097a140dSpatrick TTI::TargetCostKind CostKind); 12709467b48Spatrick /// @} 12809467b48Spatrick }; 12909467b48Spatrick 13009467b48Spatrick } // end namespace llvm 13109467b48Spatrick 13209467b48Spatrick #endif 133