LLVM  5.0.0
AArch64TargetTransformInfo.h
Go to the documentation of this file.
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"
25 #include <algorithm>
26 
27 namespace llvm {
28 
29 class AArch64TTIImpl : public BasicTTIImplBase<AArch64TTIImpl> {
31  typedef TargetTransformInfo TTI;
32  friend BaseT;
33 
34  const AArch64Subtarget *ST;
35  const AArch64TargetLowering *TLI;
36 
37  const AArch64Subtarget *getST() const { return ST; }
38  const AArch64TargetLowering *getTLI() const { return TLI; }
39 
40  enum MemIntrinsicType {
41  VECTOR_LDST_TWO_ELEMENTS,
42  VECTOR_LDST_THREE_ELEMENTS,
43  VECTOR_LDST_FOUR_ELEMENTS
44  };
45 
46  bool isWideningInstruction(Type *Ty, unsigned Opcode,
48 
49 public:
50  explicit AArch64TTIImpl(const AArch64TargetMachine *TM, const Function &F)
51  : BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)),
52  TLI(ST->getTargetLowering()) {}
53 
54  bool areInlineCompatible(const Function *Caller,
55  const Function *Callee) const;
56 
57  /// \name Scalar TTI Implementations
58  /// @{
59 
61  int getIntImmCost(int64_t Val);
62  int getIntImmCost(const APInt &Imm, Type *Ty);
63  int getIntImmCost(unsigned Opcode, unsigned Idx, const APInt &Imm, Type *Ty);
64  int getIntImmCost(Intrinsic::ID IID, unsigned Idx, const APInt &Imm,
65  Type *Ty);
66  TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth);
67 
68  /// @}
69 
70  /// \name Vector TTI Implementations
71  /// @{
72 
73  bool enableInterleavedAccessVectorization() { return true; }
74 
75  unsigned getNumberOfRegisters(bool Vector) {
76  if (Vector) {
77  if (ST->hasNEON())
78  return 32;
79  return 0;
80  }
81  return 31;
82  }
83 
84  unsigned getRegisterBitWidth(bool Vector) const {
85  if (Vector) {
86  if (ST->hasNEON())
87  return 128;
88  return 0;
89  }
90  return 64;
91  }
92 
94  return ST->getMinVectorRegisterBitWidth();
95  }
96 
97  unsigned getMaxInterleaveFactor(unsigned VF);
98 
99  int getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
100  const Instruction *I = nullptr);
101 
102  int getExtractWithExtendCost(unsigned Opcode, Type *Dst, VectorType *VecTy,
103  unsigned Index);
104 
105  int getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index);
106 
108  unsigned Opcode, Type *Ty,
114 
115  int getAddressComputationCost(Type *Ty, ScalarEvolution *SE, const SCEV *Ptr);
116 
117  int getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy,
118  const Instruction *I = nullptr);
119 
120  int getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
121  unsigned AddressSpace, const Instruction *I = nullptr);
122 
124 
126  TTI::UnrollingPreferences &UP);
127 
129  Type *ExpectedType);
130 
132 
133  int getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy, unsigned Factor,
134  ArrayRef<unsigned> Indices, unsigned Alignment,
135  unsigned AddressSpace);
136 
137  bool
139  bool &AllowPromotionWithoutCommonHeader);
140 
141  unsigned getCacheLineSize();
142 
143  unsigned getPrefetchDistance();
144 
145  unsigned getMinPrefetchStride();
146 
148 
149  bool shouldExpandReduction(const IntrinsicInst *II) const {
150  return false;
151  }
152 
153  bool useReductionIntrinsic(unsigned Opcode, Type *Ty,
154  TTI::ReductionFlags Flags) const;
155  /// @}
156 };
157 
158 } // end namespace llvm
159 
160 #endif
MachineLoop * L
TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth)
The main scalar evolution driver.
Base class which can be used to help build a TTI implementation.
Definition: BasicTTIImpl.h:40
unsigned getMaxInterleaveFactor(unsigned VF)
unsigned getIntImmCost(const APInt &Imm, Type *Ty)
int getExtractWithExtendCost(unsigned Opcode, Type *Dst, VectorType *VecTy, unsigned Index)
int getAddressComputationCost(Type *Ty, ScalarEvolution *SE, const SCEV *Ptr)
bool useReductionIntrinsic(unsigned Opcode, Type *Ty, TTI::ReductionFlags Flags) const
bool areInlineCompatible(const Function *Caller, const Function *Callee) const
#define F(x, y, z)
Definition: MD5.cpp:55
PopcntSupportKind
Flags indicating the kind of support for population count.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:33
bool getTgtMemIntrinsic(IntrinsicInst *Inst, MemIntrinsicInfo &Info)
int getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment, unsigned AddressSpace, const Instruction *I=nullptr)
Value * getOrCreateResultFromMemIntrinsic(IntrinsicInst *Inst, Type *ExpectedType)
int getIntImmCost(int64_t Val)
Calculate the cost of materializing a 64-bit value.
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
int getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index)
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
bool shouldConsiderAddressTypePromotion(const Instruction &I, bool &AllowPromotionWithoutCommonHeader)
See if I should be considered for address type promotion.
This file provides a helper that implements much of the TTI interface in terms of the target-independ...
int getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy, const Instruction *I=nullptr)
AArch64TTIImpl(const AArch64TargetMachine *TM, const Function &F)
bool shouldExpandReduction(const IntrinsicInst *II) const
OperandValueProperties
Additional properties of an operand's values.
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
AddressSpace
Definition: NVPTXBaseInfo.h:22
int getArithmeticInstrCost(unsigned Opcode, Type *Ty, TTI::OperandValueKind Opd1Info=TTI::OK_AnyValue, TTI::OperandValueKind Opd2Info=TTI::OK_AnyValue, TTI::OperandValueProperties Opd1PropInfo=TTI::OP_None, TTI::OperandValueProperties Opd2PropInfo=TTI::OP_None, ArrayRef< const Value * > Args=ArrayRef< const Value * >())
void getUnrollingPreferences(Loop *L, ScalarEvolution &SE, TTI::UnrollingPreferences &UP)
Class to represent vector types.
Definition: DerivedTypes.h:393
Class for arbitrary precision integers.
Definition: APInt.h:69
unsigned getNumberOfRegisters(bool Vector)
const DataLayout & getDataLayout() const
static std::vector< std::string > Flags
Definition: FlagsTest.cpp:8
int getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef< unsigned > Indices, unsigned Alignment, unsigned AddressSpace)
This class represents an analyzed expression in the program.
int getCostOfKeepingLiveOverCall(ArrayRef< Type * > Tys)
Represents a single loop in the control flow graph.
Definition: LoopInfo.h:360
#define I(x, y, z)
Definition: MD5.cpp:58
unsigned getMinVectorRegisterBitWidth() const
unsigned getRegisterBitWidth(bool Vector) const
LLVM Value Representation.
Definition: Value.h:73
static const Function * getParent(const Value *V)
int getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src, const Instruction *I=nullptr)
OperandValueKind
Additional information about an operand's possible values.
This pass exposes codegen information to IR-level passes.
int * Ptr
Information about a load/store intrinsic defined by the target.
A wrapper class for inspecting calls to intrinsic functions.
Definition: IntrinsicInst.h:44
This file describes how to lower LLVM code to machine code.