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;
32 const X86Subtarget *ST;
33 const X86TargetLowering *TLI;
35 unsigned getScalarizationOverhead(Type *Ty, bool Insert, bool Extract);
38 explicit X86TTIImpl(const X86TargetMachine *TM = nullptr)
39 : BaseT(TM), ST(TM ? TM->getSubtargetImpl() : nullptr),
40 TLI(ST ? ST->getTargetLowering() : nullptr) {}
42 // Provide value semantics. MSVC requires that we spell all of these out.
43 X86TTIImpl(const X86TTIImpl &Arg)
44 : BaseT(static_cast<const BaseT &>(Arg)), ST(Arg.ST), TLI(Arg.TLI) {}
45 X86TTIImpl(X86TTIImpl &&Arg)
46 : BaseT(std::move(static_cast<BaseT &>(Arg))), ST(std::move(Arg.ST)),
47 TLI(std::move(Arg.TLI)) {}
48 X86TTIImpl &operator=(const X86TTIImpl &RHS) {
49 BaseT::operator=(static_cast<const BaseT &>(RHS));
54 X86TTIImpl &operator=(X86TTIImpl &&RHS) {
55 BaseT::operator=(std::move(static_cast<BaseT &>(RHS)));
56 ST = std::move(RHS.ST);
57 TLI = std::move(RHS.TLI);
61 /// \name Scalar TTI Implementations
63 TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth);
67 /// \name Vector TTI Implementations
70 unsigned getNumberOfRegisters(bool Vector);
71 unsigned getRegisterBitWidth(bool Vector);
72 unsigned getMaxInterleaveFactor();
73 unsigned getArithmeticInstrCost(
74 unsigned Opcode, Type *Ty,
75 TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue,
76 TTI::OperandValueKind Opd2Info = TTI::OK_AnyValue,
77 TTI::OperandValueProperties Opd1PropInfo = TTI::OP_None,
78 TTI::OperandValueProperties Opd2PropInfo = TTI::OP_None);
79 unsigned getShuffleCost(TTI::ShuffleKind Kind, Type *Tp, int Index,
81 unsigned getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src);
82 unsigned getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy);
83 unsigned getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index);
84 unsigned getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
85 unsigned AddressSpace);
86 unsigned getMaskedMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
87 unsigned AddressSpace);
89 unsigned getAddressComputationCost(Type *PtrTy, bool IsComplex);
91 unsigned getReductionCost(unsigned Opcode, Type *Ty, bool IsPairwiseForm);
93 unsigned getIntImmCost(int64_t);
95 unsigned getIntImmCost(const APInt &Imm, Type *Ty);
97 unsigned getIntImmCost(unsigned Opcode, unsigned Idx, const APInt &Imm,
99 unsigned getIntImmCost(Intrinsic::ID IID, unsigned Idx, const APInt &Imm,
101 bool isLegalMaskedLoad(Type *DataType, int Consecutive);
102 bool isLegalMaskedStore(Type *DataType, int Consecutive);
107 } // end namespace llvm