1 //===-- SystemZTargetTransformInfo.h - SystemZ-specific TTI ---------------===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZTARGETTRANSFORMINFO_H
10 #define LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZTARGETTRANSFORMINFO_H
12 #include "SystemZTargetMachine.h"
13 #include "llvm/Analysis/TargetTransformInfo.h"
14 #include "llvm/CodeGen/BasicTTIImpl.h"
18 class SystemZTTIImpl : public BasicTTIImplBase<SystemZTTIImpl> {
19 typedef BasicTTIImplBase<SystemZTTIImpl> BaseT;
20 typedef TargetTransformInfo TTI;
23 const SystemZSubtarget *ST;
24 const SystemZTargetLowering *TLI;
26 const SystemZSubtarget *getST() const { return ST; }
27 const SystemZTargetLowering *getTLI() const { return TLI; }
29 unsigned const LIBCALL_COST = 30;
32 explicit SystemZTTIImpl(const SystemZTargetMachine *TM, const Function &F)
33 : BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)),
34 TLI(ST->getTargetLowering()) {}
36 /// \name Scalar TTI Implementations
39 unsigned getInliningThresholdMultiplier() { return 3; }
41 int getIntImmCost(const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind);
43 int getIntImmCostInst(unsigned Opcode, unsigned Idx, const APInt &Imm,
44 Type *Ty, TTI::TargetCostKind CostKind);
45 int getIntImmCostIntrin(Intrinsic::ID IID, unsigned Idx, const APInt &Imm,
46 Type *Ty, TTI::TargetCostKind CostKind);
48 TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth);
50 void getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
51 TTI::UnrollingPreferences &UP);
53 void getPeelingPreferences(Loop *L, ScalarEvolution &SE,
54 TTI::PeelingPreferences &PP);
56 bool isLSRCostLess(TargetTransformInfo::LSRCost &C1,
57 TargetTransformInfo::LSRCost &C2);
60 /// \name Vector TTI Implementations
63 unsigned getNumberOfRegisters(unsigned ClassID) const;
64 unsigned getRegisterBitWidth(bool Vector) const;
66 unsigned getCacheLineSize() const override { return 256; }
67 unsigned getPrefetchDistance() const override { return 4500; }
68 unsigned getMinPrefetchStride(unsigned NumMemAccesses,
69 unsigned NumStridedMemAccesses,
70 unsigned NumPrefetches,
71 bool HasCall) const override;
72 bool enableWritePrefetching() const override { return true; }
74 bool hasDivRemOp(Type *DataType, bool IsSigned);
75 bool prefersVectorizedAddressing() { return false; }
76 bool LSRWithInstrQueries() { return true; }
77 bool supportsEfficientVectorElementLoadStore() { return true; }
78 bool enableInterleavedAccessVectorization() { return true; }
80 int getArithmeticInstrCost(
81 unsigned Opcode, Type *Ty,
82 TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput,
83 TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue,
84 TTI::OperandValueKind Opd2Info = TTI::OK_AnyValue,
85 TTI::OperandValueProperties Opd1PropInfo = TTI::OP_None,
86 TTI::OperandValueProperties Opd2PropInfo = TTI::OP_None,
87 ArrayRef<const Value *> Args = ArrayRef<const Value *>(),
88 const Instruction *CxtI = nullptr);
89 int getShuffleCost(TTI::ShuffleKind Kind, VectorType *Tp, int Index,
91 unsigned getVectorTruncCost(Type *SrcTy, Type *DstTy);
92 unsigned getVectorBitmaskConversionCost(Type *SrcTy, Type *DstTy);
93 unsigned getBoolVecToIntConversionCost(unsigned Opcode, Type *Dst,
94 const Instruction *I);
95 int getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
96 TTI::TargetCostKind CostKind,
97 const Instruction *I = nullptr);
98 int getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy,
99 TTI::TargetCostKind CostKind,
100 const Instruction *I = nullptr);
101 int getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index);
102 bool isFoldableLoad(const LoadInst *Ld, const Instruction *&FoldedValue);
103 int getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment,
104 unsigned AddressSpace, TTI::TargetCostKind CostKind,
105 const Instruction *I = nullptr);
107 int getInterleavedMemoryOpCost(
108 unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices,
109 Align Alignment, unsigned AddressSpace,
110 TTI::TargetCostKind CostKind = TTI::TCK_SizeAndLatency,
111 bool UseMaskForCond = false, bool UseMaskForGaps = false);
113 int getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
114 TTI::TargetCostKind CostKind);
118 } // end namespace llvm