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