]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/Target/AArch64/AArch64TargetTransformInfo.h
Vendor import of llvm release_40 branch r292009:
[FreeBSD/FreeBSD.git] / lib / Target / AArch64 / AArch64TargetTransformInfo.h
1 //===-- AArch64TargetTransformInfo.h - AArch64 specific TTI -----*- C++ -*-===//
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 /// \file
10 /// This file a TargetTransformInfo::Concept conforming object specific to the
11 /// AArch64 target machine. It uses the target's detailed information to
12 /// provide more precise answers to certain TTI queries, while letting the
13 /// target independent and default TTI implementations handle the rest.
14 ///
15 //===----------------------------------------------------------------------===//
16
17 #ifndef LLVM_LIB_TARGET_AARCH64_AARCH64TARGETTRANSFORMINFO_H
18 #define LLVM_LIB_TARGET_AARCH64_AARCH64TARGETTRANSFORMINFO_H
19
20 #include "AArch64.h"
21 #include "AArch64TargetMachine.h"
22 #include "llvm/Analysis/TargetTransformInfo.h"
23 #include "llvm/CodeGen/BasicTTIImpl.h"
24 #include "llvm/Target/TargetLowering.h"
25 #include <algorithm>
26
27 namespace llvm {
28
29 class AArch64TTIImpl : public BasicTTIImplBase<AArch64TTIImpl> {
30   typedef BasicTTIImplBase<AArch64TTIImpl> BaseT;
31   typedef TargetTransformInfo TTI;
32   friend BaseT;
33
34   const AArch64Subtarget *ST;
35   const AArch64TargetLowering *TLI;
36
37   /// Estimate the overhead of scalarizing an instruction. Insert and Extract
38   /// are set if the result needs to be inserted and/or extracted from vectors.
39   unsigned getScalarizationOverhead(Type *Ty, bool Insert, bool Extract);
40
41   const AArch64Subtarget *getST() const { return ST; }
42   const AArch64TargetLowering *getTLI() const { return TLI; }
43
44   enum MemIntrinsicType {
45     VECTOR_LDST_TWO_ELEMENTS,
46     VECTOR_LDST_THREE_ELEMENTS,
47     VECTOR_LDST_FOUR_ELEMENTS
48   };
49
50 public:
51   explicit AArch64TTIImpl(const AArch64TargetMachine *TM, const Function &F)
52       : BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)),
53         TLI(ST->getTargetLowering()) {}
54
55   /// \name Scalar TTI Implementations
56   /// @{
57
58   using BaseT::getIntImmCost;
59   int getIntImmCost(int64_t Val);
60   int getIntImmCost(const APInt &Imm, Type *Ty);
61   int getIntImmCost(unsigned Opcode, unsigned Idx, const APInt &Imm, Type *Ty);
62   int getIntImmCost(Intrinsic::ID IID, unsigned Idx, const APInt &Imm,
63                     Type *Ty);
64   TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth);
65
66   /// @}
67
68   /// \name Vector TTI Implementations
69   /// @{
70
71   bool enableInterleavedAccessVectorization() { return true; }
72
73   unsigned getNumberOfRegisters(bool Vector) {
74     if (Vector) {
75       if (ST->hasNEON())
76         return 32;
77       return 0;
78     }
79     return 31;
80   }
81
82   unsigned getRegisterBitWidth(bool Vector) {
83     if (Vector) {
84       if (ST->hasNEON())
85         return 128;
86       return 0;
87     }
88     return 64;
89   }
90
91   unsigned getMaxInterleaveFactor(unsigned VF);
92
93   int getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src);
94
95   int getExtractWithExtendCost(unsigned Opcode, Type *Dst, VectorType *VecTy,
96                                unsigned Index);
97
98   int getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index);
99
100   int getArithmeticInstrCost(
101       unsigned Opcode, Type *Ty,
102       TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue,
103       TTI::OperandValueKind Opd2Info = TTI::OK_AnyValue,
104       TTI::OperandValueProperties Opd1PropInfo = TTI::OP_None,
105       TTI::OperandValueProperties Opd2PropInfo = TTI::OP_None,
106       ArrayRef<const Value *> Args = ArrayRef<const Value *>());
107
108   int getAddressComputationCost(Type *Ty, ScalarEvolution *SE, const SCEV *Ptr);
109
110   int getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy);
111
112   int getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
113                       unsigned AddressSpace);
114
115   int getCostOfKeepingLiveOverCall(ArrayRef<Type *> Tys);
116
117   void getUnrollingPreferences(Loop *L, TTI::UnrollingPreferences &UP);
118
119   Value *getOrCreateResultFromMemIntrinsic(IntrinsicInst *Inst,
120                                            Type *ExpectedType);
121
122   bool getTgtMemIntrinsic(IntrinsicInst *Inst, MemIntrinsicInfo &Info);
123
124   int getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy, unsigned Factor,
125                                  ArrayRef<unsigned> Indices, unsigned Alignment,
126                                  unsigned AddressSpace);
127
128   unsigned getCacheLineSize();
129
130   unsigned getPrefetchDistance();
131
132   unsigned getMinPrefetchStride();
133
134   unsigned getMaxPrefetchIterationsAhead();
135   /// @}
136 };
137
138 } // end namespace llvm
139
140 #endif