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 
27   const SystemZSubtarget *getST() const { return ST; }
28   const SystemZTargetLowering *getTLI() const { return TLI; }
29 
30   unsigned const LIBCALL_COST = 30;
31 
32 public:
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   /// @}
52 
53   /// \name Vector TTI Implementations
54   /// @{
55 
56   unsigned getNumberOfRegisters(bool Vector);
57   unsigned getRegisterBitWidth(bool Vector) const;
58 
59   bool prefersVectorizedAddressing() { return false; }
60   bool supportsEfficientVectorElementLoadStore() { return true; }
61   bool enableInterleavedAccessVectorization() { return true; }
62 
63   int getArithmeticInstrCost(
64       unsigned Opcode, Type *Ty,
65       TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue,
66       TTI::OperandValueKind Opd2Info = TTI::OK_AnyValue,
67       TTI::OperandValueProperties Opd1PropInfo = TTI::OP_None,
68       TTI::OperandValueProperties Opd2PropInfo = TTI::OP_None,
69       ArrayRef<const Value *> Args = ArrayRef<const Value *>());
70   int getShuffleCost(TTI::ShuffleKind Kind, Type *Tp, int Index, Type *SubTp);
71   unsigned getVectorTruncCost(Type *SrcTy, Type *DstTy);
72   unsigned getVectorBitmaskConversionCost(Type *SrcTy, Type *DstTy);
73   int getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
74                        const Instruction *I = nullptr);
75   int getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy,
76                          const Instruction *I = nullptr);
77   int getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index);
78   int getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
79                       unsigned AddressSpace, const Instruction *I = nullptr);
80 
81   int getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy,
82                                  unsigned Factor,
83                                  ArrayRef<unsigned> Indices,
84                                  unsigned Alignment,
85                                  unsigned AddressSpace);
86   /// @}
87 };
88 
89 } // end namespace llvm
90 
91 #endif
92