Eugene Zelenko | 96d933d | 2017-07-25 23:51:02 +0000 | [diff] [blame] | 1 | //===- AArch64TargetTransformInfo.h - AArch64 specific TTI ------*- C++ -*-===// |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 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" |
Eugene Zelenko | 96d933d | 2017-07-25 23:51:02 +0000 | [diff] [blame] | 21 | #include "AArch64Subtarget.h" |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 22 | #include "AArch64TargetMachine.h" |
Eugene Zelenko | 96d933d | 2017-07-25 23:51:02 +0000 | [diff] [blame] | 23 | #include "llvm/ADT/ArrayRef.h" |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 24 | #include "llvm/Analysis/TargetTransformInfo.h" |
| 25 | #include "llvm/CodeGen/BasicTTIImpl.h" |
Eugene Zelenko | 96d933d | 2017-07-25 23:51:02 +0000 | [diff] [blame] | 26 | #include "llvm/IR/Function.h" |
| 27 | #include "llvm/IR/Intrinsics.h" |
| 28 | #include <cstdint> |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 29 | |
| 30 | namespace llvm { |
| 31 | |
Eugene Zelenko | 96d933d | 2017-07-25 23:51:02 +0000 | [diff] [blame] | 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 | |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 42 | class AArch64TTIImpl : public BasicTTIImplBase<AArch64TTIImpl> { |
Eugene Zelenko | 96d933d | 2017-07-25 23:51:02 +0000 | [diff] [blame] | 43 | using BaseT = BasicTTIImplBase<AArch64TTIImpl>; |
| 44 | using TTI = TargetTransformInfo; |
| 45 | |
Chandler Carruth | c340ca8 | 2015-02-01 14:01:15 +0000 | [diff] [blame] | 46 | friend BaseT; |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 47 | |
| 48 | const AArch64Subtarget *ST; |
| 49 | const AArch64TargetLowering *TLI; |
| 50 | |
Chandler Carruth | c956ab66 | 2015-02-01 14:22:17 +0000 | [diff] [blame] | 51 | const AArch64Subtarget *getST() const { return ST; } |
Chandler Carruth | c340ca8 | 2015-02-01 14:01:15 +0000 | [diff] [blame] | 52 | const AArch64TargetLowering *getTLI() const { return TLI; } |
| 53 | |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 54 | enum MemIntrinsicType { |
| 55 | VECTOR_LDST_TWO_ELEMENTS, |
| 56 | VECTOR_LDST_THREE_ELEMENTS, |
| 57 | VECTOR_LDST_FOUR_ELEMENTS |
| 58 | }; |
| 59 | |
Matthew Simpson | 78fd46b | 2017-05-09 20:18:12 +0000 | [diff] [blame] | 60 | bool isWideningInstruction(Type *Ty, unsigned Opcode, |
| 61 | ArrayRef<const Value *> Args); |
| 62 | |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 63 | public: |
Eric Christopher | a4e5d3c | 2015-09-16 23:38:13 +0000 | [diff] [blame] | 64 | explicit AArch64TTIImpl(const AArch64TargetMachine *TM, const Function &F) |
Mehdi Amini | 5010ebf | 2015-07-09 02:08:42 +0000 | [diff] [blame] | 65 | : BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)), |
Chandler Carruth | c340ca8 | 2015-02-01 14:01:15 +0000 | [diff] [blame] | 66 | TLI(ST->getTargetLowering()) {} |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 67 | |
Florian Hahn | 2665feb | 2017-06-27 22:27:32 +0000 | [diff] [blame] | 68 | bool areInlineCompatible(const Function *Caller, |
| 69 | const Function *Callee) const; |
| 70 | |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 71 | /// \name Scalar TTI Implementations |
| 72 | /// @{ |
| 73 | |
| 74 | using BaseT::getIntImmCost; |
Chandler Carruth | 93205eb | 2015-08-05 18:08:10 +0000 | [diff] [blame] | 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); |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 80 | TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth); |
| 81 | |
| 82 | /// @} |
| 83 | |
| 84 | /// \name Vector TTI Implementations |
| 85 | /// @{ |
| 86 | |
Silviu Baranga | 755ec0e | 2015-09-01 11:26:46 +0000 | [diff] [blame] | 87 | bool enableInterleavedAccessVectorization() { return true; } |
| 88 | |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 89 | unsigned getNumberOfRegisters(bool Vector) { |
| 90 | if (Vector) { |
| 91 | if (ST->hasNEON()) |
| 92 | return 32; |
| 93 | return 0; |
| 94 | } |
| 95 | return 31; |
| 96 | } |
| 97 | |
Daniel Neilson | c0112ae | 2017-06-12 14:22:21 +0000 | [diff] [blame] | 98 | unsigned getRegisterBitWidth(bool Vector) const { |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 99 | if (Vector) { |
| 100 | if (ST->hasNEON()) |
| 101 | return 128; |
| 102 | return 0; |
| 103 | } |
| 104 | return 64; |
| 105 | } |
| 106 | |
Adam Nemet | e29686e | 2017-05-15 21:15:01 +0000 | [diff] [blame] | 107 | unsigned getMinVectorRegisterBitWidth() { |
| 108 | return ST->getMinVectorRegisterBitWidth(); |
| 109 | } |
| 110 | |
Wei Mi | 062c744 | 2015-05-06 17:12:25 +0000 | [diff] [blame] | 111 | unsigned getMaxInterleaveFactor(unsigned VF); |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 112 | |
Jonas Paulsson | fccc7d6 | 2017-04-12 11:49:08 +0000 | [diff] [blame] | 113 | int getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src, |
| 114 | const Instruction *I = nullptr); |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 115 | |
Matthew Simpson | e5dfb08 | 2016-04-27 15:20:21 +0000 | [diff] [blame] | 116 | int getExtractWithExtendCost(unsigned Opcode, Type *Dst, VectorType *VecTy, |
| 117 | unsigned Index); |
| 118 | |
Chandler Carruth | 93205eb | 2015-08-05 18:08:10 +0000 | [diff] [blame] | 119 | int getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index); |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 120 | |
Chandler Carruth | 93205eb | 2015-08-05 18:08:10 +0000 | [diff] [blame] | 121 | int getArithmeticInstrCost( |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 122 | unsigned Opcode, Type *Ty, |
| 123 | TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue, |
| 124 | TTI::OperandValueKind Opd2Info = TTI::OK_AnyValue, |
| 125 | TTI::OperandValueProperties Opd1PropInfo = TTI::OP_None, |
Mohammed Agabaria | 2c96c43 | 2017-01-11 08:23:37 +0000 | [diff] [blame] | 126 | TTI::OperandValueProperties Opd2PropInfo = TTI::OP_None, |
| 127 | ArrayRef<const Value *> Args = ArrayRef<const Value *>()); |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 128 | |
Mohammed Agabaria | 23599ba | 2017-01-05 14:03:41 +0000 | [diff] [blame] | 129 | int getAddressComputationCost(Type *Ty, ScalarEvolution *SE, const SCEV *Ptr); |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 130 | |
Jonas Paulsson | fccc7d6 | 2017-04-12 11:49:08 +0000 | [diff] [blame] | 131 | int getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy, |
| 132 | const Instruction *I = nullptr); |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 133 | |
Chandler Carruth | 93205eb | 2015-08-05 18:08:10 +0000 | [diff] [blame] | 134 | int getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment, |
Jonas Paulsson | fccc7d6 | 2017-04-12 11:49:08 +0000 | [diff] [blame] | 135 | unsigned AddressSpace, const Instruction *I = nullptr); |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 136 | |
Chandler Carruth | 93205eb | 2015-08-05 18:08:10 +0000 | [diff] [blame] | 137 | int getCostOfKeepingLiveOverCall(ArrayRef<Type *> Tys); |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 138 | |
Geoff Berry | 66d9bdb | 2017-06-28 15:53:17 +0000 | [diff] [blame] | 139 | void getUnrollingPreferences(Loop *L, ScalarEvolution &SE, |
| 140 | TTI::UnrollingPreferences &UP); |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 141 | |
| 142 | Value *getOrCreateResultFromMemIntrinsic(IntrinsicInst *Inst, |
| 143 | Type *ExpectedType); |
| 144 | |
| 145 | bool getTgtMemIntrinsic(IntrinsicInst *Inst, MemIntrinsicInfo &Info); |
| 146 | |
Chandler Carruth | 93205eb | 2015-08-05 18:08:10 +0000 | [diff] [blame] | 147 | int getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy, unsigned Factor, |
| 148 | ArrayRef<unsigned> Indices, unsigned Alignment, |
Dorit Nuzman | 34da6dd | 2018-10-31 09:57:56 +0000 | [diff] [blame] | 149 | unsigned AddressSpace, |
| 150 | bool UseMaskForCond = false, |
| 151 | bool UseMaskForGaps = false); |
Adam Nemet | 53e758f | 2016-03-18 00:27:29 +0000 | [diff] [blame] | 152 | |
Jun Bum Lim | dee5565 | 2017-04-03 19:20:07 +0000 | [diff] [blame] | 153 | bool |
| 154 | shouldConsiderAddressTypePromotion(const Instruction &I, |
| 155 | bool &AllowPromotionWithoutCommonHeader); |
| 156 | |
Adam Nemet | 53e758f | 2016-03-18 00:27:29 +0000 | [diff] [blame] | 157 | unsigned getCacheLineSize(); |
| 158 | |
| 159 | unsigned getPrefetchDistance(); |
Adam Nemet | 6d8beec | 2016-03-18 00:27:38 +0000 | [diff] [blame] | 160 | |
| 161 | unsigned getMinPrefetchStride(); |
Adam Nemet | 709e304 | 2016-03-18 00:27:43 +0000 | [diff] [blame] | 162 | |
| 163 | unsigned getMaxPrefetchIterationsAhead(); |
Amara Emerson | 836b0f4 | 2017-05-10 09:42:49 +0000 | [diff] [blame] | 164 | |
| 165 | bool shouldExpandReduction(const IntrinsicInst *II) const { |
| 166 | return false; |
| 167 | } |
Amara Emerson | c9916d7 | 2017-05-16 21:29:22 +0000 | [diff] [blame] | 168 | |
| 169 | bool useReductionIntrinsic(unsigned Opcode, Type *Ty, |
| 170 | TTI::ReductionFlags Flags) const; |
Matthew Simpson | eacfefd | 2018-03-16 11:34:15 +0000 | [diff] [blame] | 171 | |
| 172 | int getArithmeticReductionCost(unsigned Opcode, Type *Ty, |
| 173 | bool IsPairwiseForm); |
Matthew Simpson | b4096eb | 2018-04-26 13:48:33 +0000 | [diff] [blame] | 174 | |
| 175 | int getShuffleCost(TTI::ShuffleKind Kind, Type *Tp, int Index, Type *SubTp); |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 176 | /// @} |
| 177 | }; |
| 178 | |
| 179 | } // end namespace llvm |
| 180 | |
Eugene Zelenko | 96d933d | 2017-07-25 23:51:02 +0000 | [diff] [blame] | 181 | #endif // LLVM_LIB_TARGET_AARCH64_AARCH64TARGETTRANSFORMINFO_H |