xref: /freebsd/contrib/llvm-project/llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.h (revision 6be3386466ab79a84b48429ae66244f21526d3df)
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   int getIntImmCostIntrin(Intrinsic::ID IID, unsigned Idx, const APInt &Imm,
46                           Type *Ty, TTI::TargetCostKind CostKind);
47 
48   TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth);
49 
50   void getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
51                                TTI::UnrollingPreferences &UP);
52 
53   void getPeelingPreferences(Loop *L, ScalarEvolution &SE,
54                              TTI::PeelingPreferences &PP);
55 
56   bool isLSRCostLess(TargetTransformInfo::LSRCost &C1,
57                      TargetTransformInfo::LSRCost &C2);
58   /// @}
59 
60   /// \name Vector TTI Implementations
61   /// @{
62 
63   unsigned getNumberOfRegisters(unsigned ClassID) const;
64   unsigned getRegisterBitWidth(bool Vector) const;
65 
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; }
73 
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; }
79 
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,
90                      VectorType *SubTp);
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);
106 
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);
112 
113   int getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
114                             TTI::TargetCostKind CostKind);
115   /// @}
116 };
117 
118 } // end namespace llvm
119 
120 #endif
121