1 //===-- SystemZTargetTransformInfo.h - SystemZ-specific TTI ---------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZTARGETTRANSFORMINFO_H
11 #define LLVM_LIB_TARGET_SYSTEMZ_SYSTEMZTARGETTRANSFORMINFO_H
12 
13 #include "SystemZTargetMachine.h"
14 #include "llvm/Analysis/TargetTransformInfo.h"
15 #include "llvm/CodeGen/BasicTTIImpl.h"
16 
17 namespace llvm {
18 
19 class SystemZTTIImpl : public BasicTTIImplBase<SystemZTTIImpl> {
20   typedef BasicTTIImplBase<SystemZTTIImpl> BaseT;
21   typedef TargetTransformInfo TTI;
22   friend BaseT;
23 
24   const SystemZSubtarget *ST;
25   const SystemZTargetLowering *TLI;
26 
getST()27   const SystemZSubtarget *getST() const { return ST; }
getTLI()28   const SystemZTargetLowering *getTLI() const { return TLI; }
29 
30   unsigned const LIBCALL_COST = 30;
31 
32 public:
SystemZTTIImpl(const SystemZTargetMachine * TM,const Function & F)33   explicit SystemZTTIImpl(const SystemZTargetMachine *TM, const Function &F)
34       : BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)),
35         TLI(ST->getTargetLowering()) {}
36 
37   /// \name Scalar TTI Implementations
38   /// @{
39 
40   int getIntImmCost(const APInt &Imm, Type *Ty);
41 
42   int getIntImmCost(unsigned Opcode, unsigned Idx, const APInt &Imm, Type *Ty);
43   int getIntImmCost(Intrinsic::ID IID, unsigned Idx, const APInt &Imm,
44                     Type *Ty);
45 
46   TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth);
47 
48   void getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
49                                TTI::UnrollingPreferences &UP);
50 
51   bool isLSRCostLess(TargetTransformInfo::LSRCost &C1,
52                      TargetTransformInfo::LSRCost &C2);
53   /// @}
54 
55   /// \name Vector TTI Implementations
56   /// @{
57 
58   unsigned getNumberOfRegisters(bool Vector);
59   unsigned getRegisterBitWidth(bool Vector) const;
60 
getCacheLineSize()61   unsigned getCacheLineSize() { return 256; }
getPrefetchDistance()62   unsigned getPrefetchDistance() { return 2000; }
getMinPrefetchStride()63   unsigned getMinPrefetchStride() { return 2048; }
64 
65   bool hasDivRemOp(Type *DataType, bool IsSigned);
prefersVectorizedAddressing()66   bool prefersVectorizedAddressing() { return false; }
LSRWithInstrQueries()67   bool LSRWithInstrQueries() { return true; }
supportsEfficientVectorElementLoadStore()68   bool supportsEfficientVectorElementLoadStore() { return true; }
enableInterleavedAccessVectorization()69   bool enableInterleavedAccessVectorization() { return true; }
70 
71   int getArithmeticInstrCost(
72       unsigned Opcode, Type *Ty,
73       TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue,
74       TTI::OperandValueKind Opd2Info = TTI::OK_AnyValue,
75       TTI::OperandValueProperties Opd1PropInfo = TTI::OP_None,
76       TTI::OperandValueProperties Opd2PropInfo = TTI::OP_None,
77       ArrayRef<const Value *> Args = ArrayRef<const Value *>());
78   int getShuffleCost(TTI::ShuffleKind Kind, Type *Tp, int Index, Type *SubTp);
79   unsigned getVectorTruncCost(Type *SrcTy, Type *DstTy);
80   unsigned getVectorBitmaskConversionCost(Type *SrcTy, Type *DstTy);
81   int getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
82                        const Instruction *I = nullptr);
83   int getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy,
84                          const Instruction *I = nullptr);
85   int getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index);
86   int getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
87                       unsigned AddressSpace, const Instruction *I = nullptr);
88 
89   int getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy,
90                                  unsigned Factor,
91                                  ArrayRef<unsigned> Indices,
92                                  unsigned Alignment,
93                                  unsigned AddressSpace);
94   /// @}
95 };
96 
97 } // end namespace llvm
98 
99 #endif
100