1*9880d681SAndroid Build Coastguard Worker //===-- X86TargetTransformInfo.h - X86 specific TTI -------------*- C++ -*-===// 2*9880d681SAndroid Build Coastguard Worker // 3*9880d681SAndroid Build Coastguard Worker // The LLVM Compiler Infrastructure 4*9880d681SAndroid Build Coastguard Worker // 5*9880d681SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source 6*9880d681SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details. 7*9880d681SAndroid Build Coastguard Worker // 8*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===// 9*9880d681SAndroid Build Coastguard Worker /// \file 10*9880d681SAndroid Build Coastguard Worker /// This file a TargetTransformInfo::Concept conforming object specific to the 11*9880d681SAndroid Build Coastguard Worker /// X86 target machine. It uses the target's detailed information to 12*9880d681SAndroid Build Coastguard Worker /// provide more precise answers to certain TTI queries, while letting the 13*9880d681SAndroid Build Coastguard Worker /// target independent and default TTI implementations handle the rest. 14*9880d681SAndroid Build Coastguard Worker /// 15*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===// 16*9880d681SAndroid Build Coastguard Worker 17*9880d681SAndroid Build Coastguard Worker #ifndef LLVM_LIB_TARGET_X86_X86TARGETTRANSFORMINFO_H 18*9880d681SAndroid Build Coastguard Worker #define LLVM_LIB_TARGET_X86_X86TARGETTRANSFORMINFO_H 19*9880d681SAndroid Build Coastguard Worker 20*9880d681SAndroid Build Coastguard Worker #include "X86.h" 21*9880d681SAndroid Build Coastguard Worker #include "X86TargetMachine.h" 22*9880d681SAndroid Build Coastguard Worker #include "llvm/Analysis/TargetTransformInfo.h" 23*9880d681SAndroid Build Coastguard Worker #include "llvm/CodeGen/BasicTTIImpl.h" 24*9880d681SAndroid Build Coastguard Worker #include "llvm/Target/TargetLowering.h" 25*9880d681SAndroid Build Coastguard Worker 26*9880d681SAndroid Build Coastguard Worker namespace llvm { 27*9880d681SAndroid Build Coastguard Worker 28*9880d681SAndroid Build Coastguard Worker class X86TTIImpl : public BasicTTIImplBase<X86TTIImpl> { 29*9880d681SAndroid Build Coastguard Worker typedef BasicTTIImplBase<X86TTIImpl> BaseT; 30*9880d681SAndroid Build Coastguard Worker typedef TargetTransformInfo TTI; 31*9880d681SAndroid Build Coastguard Worker friend BaseT; 32*9880d681SAndroid Build Coastguard Worker 33*9880d681SAndroid Build Coastguard Worker const X86Subtarget *ST; 34*9880d681SAndroid Build Coastguard Worker const X86TargetLowering *TLI; 35*9880d681SAndroid Build Coastguard Worker 36*9880d681SAndroid Build Coastguard Worker int getScalarizationOverhead(Type *Ty, bool Insert, bool Extract); 37*9880d681SAndroid Build Coastguard Worker getST()38*9880d681SAndroid Build Coastguard Worker const X86Subtarget *getST() const { return ST; } getTLI()39*9880d681SAndroid Build Coastguard Worker const X86TargetLowering *getTLI() const { return TLI; } 40*9880d681SAndroid Build Coastguard Worker 41*9880d681SAndroid Build Coastguard Worker public: X86TTIImpl(const X86TargetMachine * TM,const Function & F)42*9880d681SAndroid Build Coastguard Worker explicit X86TTIImpl(const X86TargetMachine *TM, const Function &F) 43*9880d681SAndroid Build Coastguard Worker : BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)), 44*9880d681SAndroid Build Coastguard Worker TLI(ST->getTargetLowering()) {} 45*9880d681SAndroid Build Coastguard Worker 46*9880d681SAndroid Build Coastguard Worker // Provide value semantics. MSVC requires that we spell all of these out. X86TTIImpl(const X86TTIImpl & Arg)47*9880d681SAndroid Build Coastguard Worker X86TTIImpl(const X86TTIImpl &Arg) 48*9880d681SAndroid Build Coastguard Worker : BaseT(static_cast<const BaseT &>(Arg)), ST(Arg.ST), TLI(Arg.TLI) {} X86TTIImpl(X86TTIImpl && Arg)49*9880d681SAndroid Build Coastguard Worker X86TTIImpl(X86TTIImpl &&Arg) 50*9880d681SAndroid Build Coastguard Worker : BaseT(std::move(static_cast<BaseT &>(Arg))), ST(std::move(Arg.ST)), 51*9880d681SAndroid Build Coastguard Worker TLI(std::move(Arg.TLI)) {} 52*9880d681SAndroid Build Coastguard Worker 53*9880d681SAndroid Build Coastguard Worker /// \name Scalar TTI Implementations 54*9880d681SAndroid Build Coastguard Worker /// @{ 55*9880d681SAndroid Build Coastguard Worker TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth); 56*9880d681SAndroid Build Coastguard Worker 57*9880d681SAndroid Build Coastguard Worker /// @} 58*9880d681SAndroid Build Coastguard Worker 59*9880d681SAndroid Build Coastguard Worker /// \name Vector TTI Implementations 60*9880d681SAndroid Build Coastguard Worker /// @{ 61*9880d681SAndroid Build Coastguard Worker 62*9880d681SAndroid Build Coastguard Worker unsigned getNumberOfRegisters(bool Vector); 63*9880d681SAndroid Build Coastguard Worker unsigned getRegisterBitWidth(bool Vector); 64*9880d681SAndroid Build Coastguard Worker unsigned getMaxInterleaveFactor(unsigned VF); 65*9880d681SAndroid Build Coastguard Worker int getArithmeticInstrCost( 66*9880d681SAndroid Build Coastguard Worker unsigned Opcode, Type *Ty, 67*9880d681SAndroid Build Coastguard Worker TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue, 68*9880d681SAndroid Build Coastguard Worker TTI::OperandValueKind Opd2Info = TTI::OK_AnyValue, 69*9880d681SAndroid Build Coastguard Worker TTI::OperandValueProperties Opd1PropInfo = TTI::OP_None, 70*9880d681SAndroid Build Coastguard Worker TTI::OperandValueProperties Opd2PropInfo = TTI::OP_None); 71*9880d681SAndroid Build Coastguard Worker int getShuffleCost(TTI::ShuffleKind Kind, Type *Tp, int Index, Type *SubTp); 72*9880d681SAndroid Build Coastguard Worker int getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src); 73*9880d681SAndroid Build Coastguard Worker int getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy); 74*9880d681SAndroid Build Coastguard Worker int getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index); 75*9880d681SAndroid Build Coastguard Worker int getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment, 76*9880d681SAndroid Build Coastguard Worker unsigned AddressSpace); 77*9880d681SAndroid Build Coastguard Worker int getMaskedMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment, 78*9880d681SAndroid Build Coastguard Worker unsigned AddressSpace); 79*9880d681SAndroid Build Coastguard Worker int getGatherScatterOpCost(unsigned Opcode, Type *DataTy, Value *Ptr, 80*9880d681SAndroid Build Coastguard Worker bool VariableMask, unsigned Alignment); 81*9880d681SAndroid Build Coastguard Worker int getAddressComputationCost(Type *PtrTy, bool IsComplex); 82*9880d681SAndroid Build Coastguard Worker 83*9880d681SAndroid Build Coastguard Worker int getIntrinsicInstrCost(Intrinsic::ID IID, Type *RetTy, 84*9880d681SAndroid Build Coastguard Worker ArrayRef<Type *> Tys, FastMathFlags FMF); 85*9880d681SAndroid Build Coastguard Worker int getIntrinsicInstrCost(Intrinsic::ID IID, Type *RetTy, 86*9880d681SAndroid Build Coastguard Worker ArrayRef<Value *> Args, FastMathFlags FMF); 87*9880d681SAndroid Build Coastguard Worker 88*9880d681SAndroid Build Coastguard Worker int getReductionCost(unsigned Opcode, Type *Ty, bool IsPairwiseForm); 89*9880d681SAndroid Build Coastguard Worker 90*9880d681SAndroid Build Coastguard Worker int getIntImmCost(int64_t); 91*9880d681SAndroid Build Coastguard Worker 92*9880d681SAndroid Build Coastguard Worker int getIntImmCost(const APInt &Imm, Type *Ty); 93*9880d681SAndroid Build Coastguard Worker 94*9880d681SAndroid Build Coastguard Worker int getIntImmCost(unsigned Opcode, unsigned Idx, const APInt &Imm, Type *Ty); 95*9880d681SAndroid Build Coastguard Worker int getIntImmCost(Intrinsic::ID IID, unsigned Idx, const APInt &Imm, 96*9880d681SAndroid Build Coastguard Worker Type *Ty); 97*9880d681SAndroid Build Coastguard Worker bool isLegalMaskedLoad(Type *DataType); 98*9880d681SAndroid Build Coastguard Worker bool isLegalMaskedStore(Type *DataType); 99*9880d681SAndroid Build Coastguard Worker bool isLegalMaskedGather(Type *DataType); 100*9880d681SAndroid Build Coastguard Worker bool isLegalMaskedScatter(Type *DataType); 101*9880d681SAndroid Build Coastguard Worker bool areInlineCompatible(const Function *Caller, 102*9880d681SAndroid Build Coastguard Worker const Function *Callee) const; 103*9880d681SAndroid Build Coastguard Worker private: 104*9880d681SAndroid Build Coastguard Worker int getGSScalarCost(unsigned Opcode, Type *DataTy, bool VariableMask, 105*9880d681SAndroid Build Coastguard Worker unsigned Alignment, unsigned AddressSpace); 106*9880d681SAndroid Build Coastguard Worker int getGSVectorCost(unsigned Opcode, Type *DataTy, Value *Ptr, 107*9880d681SAndroid Build Coastguard Worker unsigned Alignment, unsigned AddressSpace); 108*9880d681SAndroid Build Coastguard Worker 109*9880d681SAndroid Build Coastguard Worker /// @} 110*9880d681SAndroid Build Coastguard Worker }; 111*9880d681SAndroid Build Coastguard Worker 112*9880d681SAndroid Build Coastguard Worker } // end namespace llvm 113*9880d681SAndroid Build Coastguard Worker 114*9880d681SAndroid Build Coastguard Worker #endif 115