1 //===-- X86TargetTransformInfo.h - X86 specific TTI -------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
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.
15 //===----------------------------------------------------------------------===//
17 #ifndef LLVM_LIB_TARGET_X86_X86TARGETTRANSFORMINFO_H
18 #define LLVM_LIB_TARGET_X86_X86TARGETTRANSFORMINFO_H
21 #include "X86TargetMachine.h"
22 #include "llvm/Analysis/TargetTransformInfo.h"
23 #include "llvm/CodeGen/BasicTTIImpl.h"
24 #include "llvm/Target/TargetLowering.h"
28 class X86TTIImpl : public BasicTTIImplBase<X86TTIImpl> {
29 typedef BasicTTIImplBase<X86TTIImpl> BaseT;
30 typedef TargetTransformInfo TTI;
33 const X86Subtarget *ST;
34 const X86TargetLowering *TLI;
36 int getScalarizationOverhead(Type *Ty, bool Insert, bool Extract);
38 const X86Subtarget *getST() const { return ST; }
39 const X86TargetLowering *getTLI() const { return TLI; }
42 explicit X86TTIImpl(const X86TargetMachine *TM, const Function &F)
43 : BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)),
44 TLI(ST->getTargetLowering()) {}
46 /// \name Scalar TTI Implementations
48 TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth);
52 /// \name Vector TTI Implementations
55 unsigned getNumberOfRegisters(bool Vector);
56 unsigned getRegisterBitWidth(bool Vector);
57 unsigned getMaxInterleaveFactor(unsigned VF);
58 int getArithmeticInstrCost(
59 unsigned Opcode, Type *Ty,
60 TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue,
61 TTI::OperandValueKind Opd2Info = TTI::OK_AnyValue,
62 TTI::OperandValueProperties Opd1PropInfo = TTI::OP_None,
63 TTI::OperandValueProperties Opd2PropInfo = TTI::OP_None,
64 ArrayRef<const Value *> Args = ArrayRef<const Value *>());
65 int getShuffleCost(TTI::ShuffleKind Kind, Type *Tp, int Index, Type *SubTp);
66 int getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src);
67 int getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy);
68 int getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index);
69 int getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
70 unsigned AddressSpace);
71 int getMaskedMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
72 unsigned AddressSpace);
73 int getGatherScatterOpCost(unsigned Opcode, Type *DataTy, Value *Ptr,
74 bool VariableMask, unsigned Alignment);
75 int getAddressComputationCost(Type *PtrTy, ScalarEvolution *SE,
78 int getIntrinsicInstrCost(Intrinsic::ID IID, Type *RetTy,
79 ArrayRef<Type *> Tys, FastMathFlags FMF);
80 int getIntrinsicInstrCost(Intrinsic::ID IID, Type *RetTy,
81 ArrayRef<Value *> Args, FastMathFlags FMF);
83 int getReductionCost(unsigned Opcode, Type *Ty, bool IsPairwiseForm);
85 int getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy,
86 unsigned Factor, ArrayRef<unsigned> Indices,
87 unsigned Alignment, unsigned AddressSpace);
88 int getInterleavedMemoryOpCostAVX512(unsigned Opcode, Type *VecTy,
89 unsigned Factor, ArrayRef<unsigned> Indices,
90 unsigned Alignment, unsigned AddressSpace);
92 int getIntImmCost(int64_t);
94 int getIntImmCost(const APInt &Imm, Type *Ty);
96 int getIntImmCost(unsigned Opcode, unsigned Idx, const APInt &Imm, Type *Ty);
97 int getIntImmCost(Intrinsic::ID IID, unsigned Idx, const APInt &Imm,
99 bool isLegalMaskedLoad(Type *DataType);
100 bool isLegalMaskedStore(Type *DataType);
101 bool isLegalMaskedGather(Type *DataType);
102 bool isLegalMaskedScatter(Type *DataType);
103 bool areInlineCompatible(const Function *Caller,
104 const Function *Callee) const;
106 bool enableInterleavedAccessVectorization();
108 int getGSScalarCost(unsigned Opcode, Type *DataTy, bool VariableMask,
109 unsigned Alignment, unsigned AddressSpace);
110 int getGSVectorCost(unsigned Opcode, Type *DataTy, Value *Ptr,
111 unsigned Alignment, unsigned AddressSpace);
116 } // end namespace llvm