blob: 75c62ea3233d36ec633e55ee05419cc5c8e31c29 [file] [log] [blame]
Chandler Carruth93dcdc42015-01-31 11:17:59 +00001//===-- 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
27namespace llvm {
28
29class AArch64TTIImpl : public BasicTTIImplBase<AArch64TTIImpl> {
30 typedef BasicTTIImplBase<AArch64TTIImpl> BaseT;
31 typedef TargetTransformInfo TTI;
Chandler Carruthc340ca82015-02-01 14:01:15 +000032 friend BaseT;
Chandler Carruth93dcdc42015-01-31 11:17:59 +000033
34 const AArch64Subtarget *ST;
35 const AArch64TargetLowering *TLI;
36
Chandler Carruthc956ab662015-02-01 14:22:17 +000037 const AArch64Subtarget *getST() const { return ST; }
Chandler Carruthc340ca82015-02-01 14:01:15 +000038 const AArch64TargetLowering *getTLI() const { return TLI; }
39
Chandler Carruth93dcdc42015-01-31 11:17:59 +000040 enum MemIntrinsicType {
41 VECTOR_LDST_TWO_ELEMENTS,
42 VECTOR_LDST_THREE_ELEMENTS,
43 VECTOR_LDST_FOUR_ELEMENTS
44 };
45
Matthew Simpson78fd46b2017-05-09 20:18:12 +000046 bool isWideningInstruction(Type *Ty, unsigned Opcode,
47 ArrayRef<const Value *> Args);
48
Chandler Carruth93dcdc42015-01-31 11:17:59 +000049public:
Eric Christophera4e5d3c2015-09-16 23:38:13 +000050 explicit AArch64TTIImpl(const AArch64TargetMachine *TM, const Function &F)
Mehdi Amini5010ebf2015-07-09 02:08:42 +000051 : BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)),
Chandler Carruthc340ca82015-02-01 14:01:15 +000052 TLI(ST->getTargetLowering()) {}
Chandler Carruth93dcdc42015-01-31 11:17:59 +000053
Florian Hahn2665feb2017-06-27 22:27:32 +000054 bool areInlineCompatible(const Function *Caller,
55 const Function *Callee) const;
56
Chandler Carruth93dcdc42015-01-31 11:17:59 +000057 /// \name Scalar TTI Implementations
58 /// @{
59
60 using BaseT::getIntImmCost;
Chandler Carruth93205eb2015-08-05 18:08:10 +000061 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);
Chandler Carruth93dcdc42015-01-31 11:17:59 +000066 TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth);
67
68 /// @}
69
70 /// \name Vector TTI Implementations
71 /// @{
72
Silviu Baranga755ec0e2015-09-01 11:26:46 +000073 bool enableInterleavedAccessVectorization() { return true; }
74
Chandler Carruth93dcdc42015-01-31 11:17:59 +000075 unsigned getNumberOfRegisters(bool Vector) {
76 if (Vector) {
77 if (ST->hasNEON())
78 return 32;
79 return 0;
80 }
81 return 31;
82 }
83
Daniel Neilsonc0112ae2017-06-12 14:22:21 +000084 unsigned getRegisterBitWidth(bool Vector) const {
Chandler Carruth93dcdc42015-01-31 11:17:59 +000085 if (Vector) {
86 if (ST->hasNEON())
87 return 128;
88 return 0;
89 }
90 return 64;
91 }
92
Adam Nemete29686e2017-05-15 21:15:01 +000093 unsigned getMinVectorRegisterBitWidth() {
94 return ST->getMinVectorRegisterBitWidth();
95 }
96
Wei Mi062c7442015-05-06 17:12:25 +000097 unsigned getMaxInterleaveFactor(unsigned VF);
Chandler Carruth93dcdc42015-01-31 11:17:59 +000098
Jonas Paulssonfccc7d62017-04-12 11:49:08 +000099 int getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
100 const Instruction *I = nullptr);
Chandler Carruth93dcdc42015-01-31 11:17:59 +0000101
Matthew Simpsone5dfb082016-04-27 15:20:21 +0000102 int getExtractWithExtendCost(unsigned Opcode, Type *Dst, VectorType *VecTy,
103 unsigned Index);
104
Chandler Carruth93205eb2015-08-05 18:08:10 +0000105 int getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index);
Chandler Carruth93dcdc42015-01-31 11:17:59 +0000106
Chandler Carruth93205eb2015-08-05 18:08:10 +0000107 int getArithmeticInstrCost(
Chandler Carruth93dcdc42015-01-31 11:17:59 +0000108 unsigned Opcode, Type *Ty,
109 TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue,
110 TTI::OperandValueKind Opd2Info = TTI::OK_AnyValue,
111 TTI::OperandValueProperties Opd1PropInfo = TTI::OP_None,
Mohammed Agabaria2c96c432017-01-11 08:23:37 +0000112 TTI::OperandValueProperties Opd2PropInfo = TTI::OP_None,
113 ArrayRef<const Value *> Args = ArrayRef<const Value *>());
Chandler Carruth93dcdc42015-01-31 11:17:59 +0000114
Mohammed Agabaria23599ba2017-01-05 14:03:41 +0000115 int getAddressComputationCost(Type *Ty, ScalarEvolution *SE, const SCEV *Ptr);
Chandler Carruth93dcdc42015-01-31 11:17:59 +0000116
Jonas Paulssonfccc7d62017-04-12 11:49:08 +0000117 int getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy,
118 const Instruction *I = nullptr);
Chandler Carruth93dcdc42015-01-31 11:17:59 +0000119
Chandler Carruth93205eb2015-08-05 18:08:10 +0000120 int getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
Jonas Paulssonfccc7d62017-04-12 11:49:08 +0000121 unsigned AddressSpace, const Instruction *I = nullptr);
Chandler Carruth93dcdc42015-01-31 11:17:59 +0000122
Chandler Carruth93205eb2015-08-05 18:08:10 +0000123 int getCostOfKeepingLiveOverCall(ArrayRef<Type *> Tys);
Chandler Carruth93dcdc42015-01-31 11:17:59 +0000124
Chandler Carruthab5cb362015-02-01 14:31:23 +0000125 void getUnrollingPreferences(Loop *L, TTI::UnrollingPreferences &UP);
Chandler Carruth93dcdc42015-01-31 11:17:59 +0000126
127 Value *getOrCreateResultFromMemIntrinsic(IntrinsicInst *Inst,
128 Type *ExpectedType);
129
130 bool getTgtMemIntrinsic(IntrinsicInst *Inst, MemIntrinsicInfo &Info);
131
Chandler Carruth93205eb2015-08-05 18:08:10 +0000132 int getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy, unsigned Factor,
133 ArrayRef<unsigned> Indices, unsigned Alignment,
134 unsigned AddressSpace);
Adam Nemet53e758f2016-03-18 00:27:29 +0000135
Jun Bum Limdee55652017-04-03 19:20:07 +0000136 bool
137 shouldConsiderAddressTypePromotion(const Instruction &I,
138 bool &AllowPromotionWithoutCommonHeader);
139
Adam Nemet53e758f2016-03-18 00:27:29 +0000140 unsigned getCacheLineSize();
141
142 unsigned getPrefetchDistance();
Adam Nemet6d8beec2016-03-18 00:27:38 +0000143
144 unsigned getMinPrefetchStride();
Adam Nemet709e3042016-03-18 00:27:43 +0000145
146 unsigned getMaxPrefetchIterationsAhead();
Amara Emerson836b0f42017-05-10 09:42:49 +0000147
148 bool shouldExpandReduction(const IntrinsicInst *II) const {
149 return false;
150 }
Amara Emersonc9916d72017-05-16 21:29:22 +0000151
152 bool useReductionIntrinsic(unsigned Opcode, Type *Ty,
153 TTI::ReductionFlags Flags) const;
Chandler Carruth93dcdc42015-01-31 11:17:59 +0000154 /// @}
155};
156
157} // end namespace llvm
158
159#endif