LLVM  4.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  /// 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 
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 
101  unsigned Opcode, Type *Ty,
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 
116 
117  void getUnrollingPreferences(Loop *L, TTI::UnrollingPreferences &UP);
118 
120  Type *ExpectedType);
121 
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 
135  /// @}
136 };
137 
138 } // end namespace llvm
139 
140 #endif
MachineLoop * L
TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth)
The main scalar evolution driver.
int getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment, unsigned AddressSpace)
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)
#define F(x, y, z)
Definition: MD5.cpp:51
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)
Value * getOrCreateResultFromMemIntrinsic(IntrinsicInst *Inst, Type *ExpectedType)
int getIntImmCost(int64_t Val)
Calculate the cost of materializing a 64-bit value.
unsigned getRegisterBitWidth(bool Vector)
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
int getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index)
This file provides a helper that implements much of the TTI interface in terms of the target-independ...
AArch64TTIImpl(const AArch64TargetMachine *TM, const Function &F)
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 * >())
int getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy)
Class to represent vector types.
Definition: DerivedTypes.h:369
Class for arbitrary precision integers.
Definition: APInt.h:77
unsigned getNumberOfRegisters(bool Vector)
const DataLayout & getDataLayout() const
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 getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src)
int getCostOfKeepingLiveOverCall(ArrayRef< Type * > Tys)
Represents a single loop in the control flow graph.
Definition: LoopInfo.h:368
void getUnrollingPreferences(Loop *L, TTI::UnrollingPreferences &UP)
LLVM Value Representation.
Definition: Value.h:71
static const Function * getParent(const Value *V)
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.