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