Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 1 | //===-- X86TargetTransformInfo.h - X86 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 | /// X86 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_X86_X86TARGETTRANSFORMINFO_H |
| 18 | #define LLVM_LIB_TARGET_X86_X86TARGETTRANSFORMINFO_H |
| 19 | |
| 20 | #include "X86.h" |
| 21 | #include "X86TargetMachine.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 X86TTIImpl : public BasicTTIImplBase<X86TTIImpl> { |
| 29 | typedef BasicTTIImplBase<X86TTIImpl> 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 | |
Chandler Carruth | c340ca8 | 2015-02-01 14:01:15 +0000 | [diff] [blame^] | 33 | const X86TargetMachine *TM; |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 34 | const X86Subtarget *ST; |
| 35 | const X86TargetLowering *TLI; |
| 36 | |
| 37 | unsigned getScalarizationOverhead(Type *Ty, bool Insert, bool Extract); |
| 38 | |
Chandler Carruth | c340ca8 | 2015-02-01 14:01:15 +0000 | [diff] [blame^] | 39 | const X86TargetMachine *getTM() const { return TM; } |
| 40 | const X86TargetLowering *getTLI() const { return TLI; } |
| 41 | |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 42 | public: |
Chandler Carruth | 8b04c0d | 2015-02-01 13:20:00 +0000 | [diff] [blame] | 43 | explicit X86TTIImpl(const X86TargetMachine *TM, Function &F) |
Chandler Carruth | c340ca8 | 2015-02-01 14:01:15 +0000 | [diff] [blame^] | 44 | : BaseT(TM), TM(TM), ST(TM->getSubtargetImpl(F)), |
| 45 | TLI(ST->getTargetLowering()) {} |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 46 | |
| 47 | // Provide value semantics. MSVC requires that we spell all of these out. |
| 48 | X86TTIImpl(const X86TTIImpl &Arg) |
Chandler Carruth | c340ca8 | 2015-02-01 14:01:15 +0000 | [diff] [blame^] | 49 | : BaseT(static_cast<const BaseT &>(Arg)), TM(Arg.TM), ST(Arg.ST), |
| 50 | TLI(Arg.TLI) {} |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 51 | X86TTIImpl(X86TTIImpl &&Arg) |
Chandler Carruth | c340ca8 | 2015-02-01 14:01:15 +0000 | [diff] [blame^] | 52 | : BaseT(std::move(static_cast<BaseT &>(Arg))), TM(std::move(Arg.TM)), |
| 53 | ST(std::move(Arg.ST)), TLI(std::move(Arg.TLI)) {} |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 54 | X86TTIImpl &operator=(const X86TTIImpl &RHS) { |
| 55 | BaseT::operator=(static_cast<const BaseT &>(RHS)); |
Chandler Carruth | c340ca8 | 2015-02-01 14:01:15 +0000 | [diff] [blame^] | 56 | TM = RHS.TM; |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 57 | ST = RHS.ST; |
| 58 | TLI = RHS.TLI; |
| 59 | return *this; |
| 60 | } |
| 61 | X86TTIImpl &operator=(X86TTIImpl &&RHS) { |
| 62 | BaseT::operator=(std::move(static_cast<BaseT &>(RHS))); |
Chandler Carruth | c340ca8 | 2015-02-01 14:01:15 +0000 | [diff] [blame^] | 63 | TM = std::move(RHS.TM); |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 64 | ST = std::move(RHS.ST); |
| 65 | TLI = std::move(RHS.TLI); |
| 66 | return *this; |
| 67 | } |
| 68 | |
| 69 | /// \name Scalar TTI Implementations |
| 70 | /// @{ |
| 71 | TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth); |
| 72 | |
| 73 | /// @} |
| 74 | |
| 75 | /// \name Vector TTI Implementations |
| 76 | /// @{ |
| 77 | |
| 78 | unsigned getNumberOfRegisters(bool Vector); |
| 79 | unsigned getRegisterBitWidth(bool Vector); |
| 80 | unsigned getMaxInterleaveFactor(); |
| 81 | unsigned getArithmeticInstrCost( |
| 82 | unsigned Opcode, Type *Ty, |
| 83 | TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue, |
| 84 | TTI::OperandValueKind Opd2Info = TTI::OK_AnyValue, |
| 85 | TTI::OperandValueProperties Opd1PropInfo = TTI::OP_None, |
| 86 | TTI::OperandValueProperties Opd2PropInfo = TTI::OP_None); |
| 87 | unsigned getShuffleCost(TTI::ShuffleKind Kind, Type *Tp, int Index, |
| 88 | Type *SubTp); |
| 89 | unsigned getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src); |
| 90 | unsigned getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy); |
| 91 | unsigned getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index); |
| 92 | unsigned getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment, |
| 93 | unsigned AddressSpace); |
| 94 | unsigned getMaskedMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment, |
| 95 | unsigned AddressSpace); |
| 96 | |
| 97 | unsigned getAddressComputationCost(Type *PtrTy, bool IsComplex); |
| 98 | |
| 99 | unsigned getReductionCost(unsigned Opcode, Type *Ty, bool IsPairwiseForm); |
| 100 | |
| 101 | unsigned getIntImmCost(int64_t); |
| 102 | |
| 103 | unsigned getIntImmCost(const APInt &Imm, Type *Ty); |
| 104 | |
| 105 | unsigned getIntImmCost(unsigned Opcode, unsigned Idx, const APInt &Imm, |
| 106 | Type *Ty); |
| 107 | unsigned getIntImmCost(Intrinsic::ID IID, unsigned Idx, const APInt &Imm, |
| 108 | Type *Ty); |
| 109 | bool isLegalMaskedLoad(Type *DataType, int Consecutive); |
| 110 | bool isLegalMaskedStore(Type *DataType, int Consecutive); |
| 111 | |
| 112 | /// @} |
| 113 | }; |
Chandler Carruth | 93dcdc4 | 2015-01-31 11:17:59 +0000 | [diff] [blame] | 114 | |
| 115 | } // end namespace llvm |
| 116 | |
| 117 | #endif |