Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 1 | //===-- ARMTargetTransformInfo.h - ARM 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 | /// ARM 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_ARM_ARMTARGETTRANSFORMINFO_H |
| 18 | #define LLVM_LIB_TARGET_ARM_ARMTARGETTRANSFORMINFO_H |
| 19 | |
| 20 | #include "ARM.h" |
| 21 | #include "ARMTargetMachine.h" |
| 22 | #include "llvm/Analysis/TargetTransformInfo.h" |
| 23 | #include "llvm/CodeGen/BasicTTIImpl.h" |
| 24 | #include "llvm/Target/TargetLowering.h" |
| 25 | |
| 26 | namespace llvm { |
| 27 | |
| 28 | class ARMTTIImpl : public BasicTTIImplBase<ARMTTIImpl> { |
| 29 | typedef BasicTTIImplBase<ARMTTIImpl> BaseT; |
| 30 | typedef TargetTransformInfo TTI; |
Chandler Carruth | c340ca8 | 2015-02-01 14:01:15 +0000 | [diff] [blame] | 31 | friend BaseT; |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 32 | |
| 33 | const ARMSubtarget *ST; |
| 34 | const ARMTargetLowering *TLI; |
| 35 | |
| 36 | /// Estimate the overhead of scalarizing an instruction. Insert and Extract |
| 37 | /// are set if the result needs to be inserted and/or extracted from vectors. |
| 38 | unsigned getScalarizationOverhead(Type *Ty, bool Insert, bool Extract); |
| 39 | |
Chandler Carruth | c956ab66 | 2015-02-01 14:22:17 +0000 | [diff] [blame] | 40 | const ARMSubtarget *getST() const { return ST; } |
Chandler Carruth | c340ca8 | 2015-02-01 14:01:15 +0000 | [diff] [blame] | 41 | const ARMTargetLowering *getTLI() const { return TLI; } |
| 42 | |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 43 | public: |
Eric Christopher | a4e5d3c | 2015-09-16 23:38:13 +0000 | [diff] [blame] | 44 | explicit ARMTTIImpl(const ARMBaseTargetMachine *TM, const Function &F) |
Mehdi Amini | 5010ebf | 2015-07-09 02:08:42 +0000 | [diff] [blame] | 45 | : BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)), |
| 46 | TLI(ST->getTargetLowering()) {} |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 47 | |
Silviu Baranga | e748c9e | 2015-09-01 11:19:15 +0000 | [diff] [blame] | 48 | bool enableInterleavedAccessVectorization() { return true; } |
| 49 | |
Renato Golin | 4b18a51 | 2016-04-18 12:06:47 +0000 | [diff] [blame] | 50 | /// Floating-point computation using ARMv8 AArch32 Advanced |
| 51 | /// SIMD instructions remains unchanged from ARMv7. Only AArch64 SIMD |
| 52 | /// is IEEE-754 compliant, but it's not covered in this target. |
Renato Golin | 5cb666a | 2016-04-14 20:42:18 +0000 | [diff] [blame] | 53 | bool isFPVectorizationPotentiallyUnsafe() { |
Renato Golin | 4b18a51 | 2016-04-18 12:06:47 +0000 | [diff] [blame] | 54 | return !ST->isTargetDarwin(); |
Renato Golin | 5cb666a | 2016-04-14 20:42:18 +0000 | [diff] [blame] | 55 | } |
| 56 | |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 57 | /// \name Scalar TTI Implementations |
| 58 | /// @{ |
| 59 | |
Sjoerd Meijer | 38c2cd0 | 2016-07-14 07:44:20 +0000 | [diff] [blame] | 60 | int getIntImmCodeSizeCost(unsigned Opcode, unsigned Idx, const APInt &Imm, |
| 61 | Type *Ty); |
| 62 | |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 63 | using BaseT::getIntImmCost; |
Chandler Carruth | 93205eb | 2015-08-05 18:08:10 +0000 | [diff] [blame] | 64 | int getIntImmCost(const APInt &Imm, Type *Ty); |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 65 | |
Tim Northover | 903f81b | 2016-04-15 18:17:18 +0000 | [diff] [blame] | 66 | int getIntImmCost(unsigned Opcode, unsigned Idx, const APInt &Imm, Type *Ty); |
Tim Northover | 5c02f9a | 2016-04-13 23:08:27 +0000 | [diff] [blame] | 67 | |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 68 | /// @} |
| 69 | |
| 70 | /// \name Vector TTI Implementations |
| 71 | /// @{ |
| 72 | |
| 73 | unsigned getNumberOfRegisters(bool Vector) { |
| 74 | if (Vector) { |
| 75 | if (ST->hasNEON()) |
| 76 | return 16; |
| 77 | return 0; |
| 78 | } |
| 79 | |
| 80 | if (ST->isThumb1Only()) |
| 81 | return 8; |
| 82 | return 13; |
| 83 | } |
| 84 | |
| 85 | unsigned getRegisterBitWidth(bool Vector) { |
| 86 | if (Vector) { |
| 87 | if (ST->hasNEON()) |
| 88 | return 128; |
| 89 | return 0; |
| 90 | } |
| 91 | |
| 92 | return 32; |
| 93 | } |
| 94 | |
Wei Mi | 062c744 | 2015-05-06 17:12:25 +0000 | [diff] [blame] | 95 | unsigned getMaxInterleaveFactor(unsigned VF) { |
Diana Picus | 92423ce | 2016-06-27 09:08:23 +0000 | [diff] [blame] | 96 | return ST->getMaxInterleaveFactor(); |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 97 | } |
| 98 | |
Chandler Carruth | 93205eb | 2015-08-05 18:08:10 +0000 | [diff] [blame] | 99 | int getShuffleCost(TTI::ShuffleKind Kind, Type *Tp, int Index, Type *SubTp); |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 100 | |
Chandler Carruth | 93205eb | 2015-08-05 18:08:10 +0000 | [diff] [blame] | 101 | int getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src); |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 102 | |
Chandler Carruth | 93205eb | 2015-08-05 18:08:10 +0000 | [diff] [blame] | 103 | int getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy); |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 104 | |
Chandler Carruth | 93205eb | 2015-08-05 18:08:10 +0000 | [diff] [blame] | 105 | int getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index); |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 106 | |
Mohammed Agabaria | 23599ba | 2017-01-05 14:03:41 +0000 | [diff] [blame^] | 107 | int getAddressComputationCost(Type *Val, ScalarEvolution *SE, |
| 108 | const SCEV *Ptr); |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 109 | |
Chandler Carruth | 93205eb | 2015-08-05 18:08:10 +0000 | [diff] [blame] | 110 | int getFPOpCost(Type *Ty); |
Cameron Esfahani | 17177d1 | 2015-02-05 02:09:33 +0000 | [diff] [blame] | 111 | |
Chandler Carruth | 93205eb | 2015-08-05 18:08:10 +0000 | [diff] [blame] | 112 | int getArithmeticInstrCost( |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 113 | unsigned Opcode, Type *Ty, |
| 114 | TTI::OperandValueKind Op1Info = TTI::OK_AnyValue, |
| 115 | TTI::OperandValueKind Op2Info = TTI::OK_AnyValue, |
| 116 | TTI::OperandValueProperties Opd1PropInfo = TTI::OP_None, |
| 117 | TTI::OperandValueProperties Opd2PropInfo = TTI::OP_None); |
| 118 | |
Chandler Carruth | 93205eb | 2015-08-05 18:08:10 +0000 | [diff] [blame] | 119 | int getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment, |
| 120 | unsigned AddressSpace); |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 121 | |
Chandler Carruth | 93205eb | 2015-08-05 18:08:10 +0000 | [diff] [blame] | 122 | int getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy, unsigned Factor, |
| 123 | ArrayRef<unsigned> Indices, unsigned Alignment, |
| 124 | unsigned AddressSpace); |
Oliver Stannard | 4df1cc0 | 2016-10-07 08:48:24 +0000 | [diff] [blame] | 125 | |
| 126 | bool shouldBuildLookupTablesForConstant(Constant *C) const { |
| 127 | // In the ROPI and RWPI relocation models we can't have pointers to global |
| 128 | // variables or functions in constant data, so don't convert switches to |
| 129 | // lookup tables if any of the values would need relocation. |
| 130 | if (ST->isROPI() || ST->isRWPI()) |
| 131 | return !C->needsRelocation(); |
| 132 | |
| 133 | return true; |
| 134 | } |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 135 | /// @} |
| 136 | }; |
| 137 | |
| 138 | } // end namespace llvm |
| 139 | |
| 140 | #endif |