LLVM  8.0.1
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 "AArch64Subtarget.h"
22 #include "AArch64TargetMachine.h"
23 #include "llvm/ADT/ArrayRef.h"
26 #include "llvm/IR/Function.h"
27 #include "llvm/IR/Intrinsics.h"
28 #include <cstdint>
29 
30 namespace llvm {
31 
32 class APInt;
33 class Instruction;
34 class IntrinsicInst;
35 class Loop;
36 class SCEV;
37 class ScalarEvolution;
38 class Type;
39 class Value;
40 class VectorType;
41 
42 class AArch64TTIImpl : public BasicTTIImplBase<AArch64TTIImpl> {
44  using TTI = TargetTransformInfo;
45 
46  friend BaseT;
47 
48  const AArch64Subtarget *ST;
49  const AArch64TargetLowering *TLI;
50 
51  const AArch64Subtarget *getST() const { return ST; }
52  const AArch64TargetLowering *getTLI() const { return TLI; }
53 
54  enum MemIntrinsicType {
55  VECTOR_LDST_TWO_ELEMENTS,
56  VECTOR_LDST_THREE_ELEMENTS,
57  VECTOR_LDST_FOUR_ELEMENTS
58  };
59 
60  bool isWideningInstruction(Type *Ty, unsigned Opcode,
62 
63 public:
64  explicit AArch64TTIImpl(const AArch64TargetMachine *TM, const Function &F)
65  : BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)),
66  TLI(ST->getTargetLowering()) {}
67 
68  bool areInlineCompatible(const Function *Caller,
69  const Function *Callee) const;
70 
71  /// \name Scalar TTI Implementations
72  /// @{
73 
75  int getIntImmCost(int64_t Val);
76  int getIntImmCost(const APInt &Imm, Type *Ty);
77  int getIntImmCost(unsigned Opcode, unsigned Idx, const APInt &Imm, Type *Ty);
78  int getIntImmCost(Intrinsic::ID IID, unsigned Idx, const APInt &Imm,
79  Type *Ty);
80  TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth);
81 
82  /// @}
83 
84  /// \name Vector TTI Implementations
85  /// @{
86 
87  bool enableInterleavedAccessVectorization() { return true; }
88 
89  unsigned getNumberOfRegisters(bool Vector) {
90  if (Vector) {
91  if (ST->hasNEON())
92  return 32;
93  return 0;
94  }
95  return 31;
96  }
97 
98  unsigned getRegisterBitWidth(bool Vector) const {
99  if (Vector) {
100  if (ST->hasNEON())
101  return 128;
102  return 0;
103  }
104  return 64;
105  }
106 
108  return ST->getMinVectorRegisterBitWidth();
109  }
110 
111  unsigned getMaxInterleaveFactor(unsigned VF);
112 
113  int getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
114  const Instruction *I = nullptr);
115 
116  int getExtractWithExtendCost(unsigned Opcode, Type *Dst, VectorType *VecTy,
117  unsigned Index);
118 
119  int getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index);
120 
122  unsigned Opcode, Type *Ty,
128 
129  int getAddressComputationCost(Type *Ty, ScalarEvolution *SE, const SCEV *Ptr);
130 
131  int getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy,
132  const Instruction *I = nullptr);
133 
134  int getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
135  unsigned AddressSpace, const Instruction *I = nullptr);
136 
138 
141 
143  Type *ExpectedType);
144 
146 
147  int getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy, unsigned Factor,
148  ArrayRef<unsigned> Indices, unsigned Alignment,
149  unsigned AddressSpace,
150  bool UseMaskForCond = false,
151  bool UseMaskForGaps = false);
152 
153  bool
155  bool &AllowPromotionWithoutCommonHeader);
156 
157  unsigned getCacheLineSize();
158 
159  unsigned getPrefetchDistance();
160 
161  unsigned getMinPrefetchStride();
162 
164 
165  bool shouldExpandReduction(const IntrinsicInst *II) const {
166  return false;
167  }
168 
169  bool useReductionIntrinsic(unsigned Opcode, Type *Ty,
170  TTI::ReductionFlags Flags) const;
171 
172  int getArithmeticReductionCost(unsigned Opcode, Type *Ty,
173  bool IsPairwiseForm);
174 
175  int getShuffleCost(TTI::ShuffleKind Kind, Type *Tp, int Index, Type *SubTp);
176  /// @}
177 };
178 
179 } // end namespace llvm
180 
181 #endif // LLVM_LIB_TARGET_AARCH64_AARCH64TARGETTRANSFORMINFO_H
Type
MessagePack types as defined in the standard, with the exception of Integer being divided into a sign...
Definition: MsgPackReader.h:49
This class represents lattice values for constants.
Definition: AllocatorList.h:24
TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth)
The main scalar evolution driver.
unsigned getRegisterBitWidth(bool Vector) const
F(f)
Base class which can be used to help build a TTI implementation.
Definition: BasicTTIImpl.h:78
unsigned getMaxInterleaveFactor(unsigned VF)
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 *>())
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)
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
amdgpu Simplify well known AMD library false Value * Callee
Analysis containing CSE Info
Definition: CSEInfo.cpp:21
bool getTgtMemIntrinsic(IntrinsicInst *Inst, MemIntrinsicInfo &Info)
unsigned getMinVectorRegisterBitWidth() const
int getShuffleCost(TTI::ShuffleKind Kind, Type *Tp, int Index, Type *SubTp)
int getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment, unsigned AddressSpace, const Instruction *I=nullptr)
bool useReductionIntrinsic(unsigned Opcode, Type *Ty, TTI::ReductionFlags Flags) const
Value * getOrCreateResultFromMemIntrinsic(IntrinsicInst *Inst, Type *ExpectedType)
int getIntImmCost(int64_t Val)
Calculate the cost of materializing a 64-bit value.
Flags describing the kind of vector reduction.
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)
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)
int getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef< unsigned > Indices, unsigned Alignment, unsigned AddressSpace, bool UseMaskForCond=false, bool UseMaskForGaps=false)
bool shouldExpandReduction(const IntrinsicInst *II) const
AArch64TTIImpl(const AArch64TargetMachine *TM, const Function &F)
OperandValueProperties
Additional properties of an operand&#39;s values.
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
bool areInlineCompatible(const Function *Caller, const Function *Callee) const
int getCostOfKeepingLiveOverCall(ArrayRef< Type *> Tys)
AddressSpace
Definition: NVPTXBaseInfo.h:22
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:70
int getArithmeticReductionCost(unsigned Opcode, Type *Ty, bool IsPairwiseForm)
unsigned getNumberOfRegisters(bool Vector)
This class represents an analyzed expression in the program.
Represents a single loop in the control flow graph.
Definition: LoopInfo.h:465
Parameters that control the generic loop unrolling transformation.
#define I(x, y, z)
Definition: MD5.cpp:58
const unsigned Kind
LLVM Value Representation.
Definition: Value.h:73
static const Function * getParent(const Value *V)
const DataLayout & getDataLayout() const
int getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src, const Instruction *I=nullptr)
OperandValueKind
Additional information about an operand&#39;s possible values.
This pass exposes codegen information to IR-level passes.
Information about a load/store intrinsic defined by the target.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
A wrapper class for inspecting calls to intrinsic functions.
Definition: IntrinsicInst.h:44
ShuffleKind
The various kinds of shuffle patterns for vector queries.