xref: /freebsd/contrib/llvm-project/llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.h (revision 5def4c47d4bd90b209b9b4a4ba9faec15846d8fd)
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   unsigned getRegisterBitWidth(bool Vector) 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   int 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   int getShuffleCost(TTI::ShuffleKind Kind, VectorType *Tp, int Index,
91                      VectorType *SubTp);
92   unsigned getVectorTruncCost(Type *SrcTy, Type *DstTy);
93   unsigned getVectorBitmaskConversionCost(Type *SrcTy, Type *DstTy);
94   unsigned getBoolVecToIntConversionCost(unsigned Opcode, Type *Dst,
95                                          const Instruction *I);
96   int getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
97                        TTI::CastContextHint CCH, TTI::TargetCostKind CostKind,
98                        const Instruction *I = nullptr);
99   int getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy,
100                          CmpInst::Predicate VecPred,
101                          TTI::TargetCostKind CostKind,
102                          const Instruction *I = nullptr);
103   int getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index);
104   bool isFoldableLoad(const LoadInst *Ld, const Instruction *&FoldedValue);
105   int getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment,
106                       unsigned AddressSpace, TTI::TargetCostKind CostKind,
107                       const Instruction *I = nullptr);
108 
109   int getInterleavedMemoryOpCost(
110       unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices,
111       Align Alignment, unsigned AddressSpace,
112       TTI::TargetCostKind CostKind = TTI::TCK_SizeAndLatency,
113       bool UseMaskForCond = false, bool UseMaskForGaps = false);
114 
115   int getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
116                             TTI::TargetCostKind CostKind);
117   /// @}
118 };
119 
120 } // end namespace llvm
121 
122 #endif
123