blob: 9f0adcfef623a561a2f6ffcea8f362216ad7ab12 [file] [log] [blame]
Chandler Carruth93dcdc42015-01-31 11:17:59 +00001//===-- 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
26namespace llvm {
27
28class X86TTIImpl : public BasicTTIImplBase<X86TTIImpl> {
29 typedef BasicTTIImplBase<X86TTIImpl> BaseT;
30 typedef TargetTransformInfo TTI;
Chandler Carruthc340ca82015-02-01 14:01:15 +000031 friend BaseT;
Chandler Carruth93dcdc42015-01-31 11:17:59 +000032
33 const X86Subtarget *ST;
34 const X86TargetLowering *TLI;
35
36 unsigned getScalarizationOverhead(Type *Ty, bool Insert, bool Extract);
37
Chandler Carruthc956ab662015-02-01 14:22:17 +000038 const X86Subtarget *getST() const { return ST; }
Chandler Carruthc340ca82015-02-01 14:01:15 +000039 const X86TargetLowering *getTLI() const { return TLI; }
40
Chandler Carruth93dcdc42015-01-31 11:17:59 +000041public:
Chandler Carruth8b04c0d2015-02-01 13:20:00 +000042 explicit X86TTIImpl(const X86TargetMachine *TM, Function &F)
Chandler Carruthc956ab662015-02-01 14:22:17 +000043 : BaseT(TM), ST(TM->getSubtargetImpl(F)), TLI(ST->getTargetLowering()) {}
Chandler Carruth93dcdc42015-01-31 11:17:59 +000044
45 // Provide value semantics. MSVC requires that we spell all of these out.
46 X86TTIImpl(const X86TTIImpl &Arg)
Chandler Carruthc956ab662015-02-01 14:22:17 +000047 : BaseT(static_cast<const BaseT &>(Arg)), ST(Arg.ST), TLI(Arg.TLI) {}
Chandler Carruth93dcdc42015-01-31 11:17:59 +000048 X86TTIImpl(X86TTIImpl &&Arg)
Chandler Carruthc956ab662015-02-01 14:22:17 +000049 : BaseT(std::move(static_cast<BaseT &>(Arg))), ST(std::move(Arg.ST)),
50 TLI(std::move(Arg.TLI)) {}
Chandler Carruth93dcdc42015-01-31 11:17:59 +000051 X86TTIImpl &operator=(const X86TTIImpl &RHS) {
52 BaseT::operator=(static_cast<const BaseT &>(RHS));
53 ST = RHS.ST;
54 TLI = RHS.TLI;
55 return *this;
56 }
57 X86TTIImpl &operator=(X86TTIImpl &&RHS) {
58 BaseT::operator=(std::move(static_cast<BaseT &>(RHS)));
59 ST = std::move(RHS.ST);
60 TLI = std::move(RHS.TLI);
61 return *this;
62 }
63
64 /// \name Scalar TTI Implementations
65 /// @{
66 TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth);
67
68 /// @}
69
70 /// \name Vector TTI Implementations
71 /// @{
72
73 unsigned getNumberOfRegisters(bool Vector);
74 unsigned getRegisterBitWidth(bool Vector);
75 unsigned getMaxInterleaveFactor();
76 unsigned getArithmeticInstrCost(
77 unsigned Opcode, Type *Ty,
78 TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue,
79 TTI::OperandValueKind Opd2Info = TTI::OK_AnyValue,
80 TTI::OperandValueProperties Opd1PropInfo = TTI::OP_None,
81 TTI::OperandValueProperties Opd2PropInfo = TTI::OP_None);
82 unsigned getShuffleCost(TTI::ShuffleKind Kind, Type *Tp, int Index,
83 Type *SubTp);
84 unsigned getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src);
85 unsigned getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy);
86 unsigned getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index);
87 unsigned getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
88 unsigned AddressSpace);
89 unsigned getMaskedMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
90 unsigned AddressSpace);
91
92 unsigned getAddressComputationCost(Type *PtrTy, bool IsComplex);
93
94 unsigned getReductionCost(unsigned Opcode, Type *Ty, bool IsPairwiseForm);
95
96 unsigned getIntImmCost(int64_t);
97
98 unsigned getIntImmCost(const APInt &Imm, Type *Ty);
99
100 unsigned getIntImmCost(unsigned Opcode, unsigned Idx, const APInt &Imm,
101 Type *Ty);
102 unsigned getIntImmCost(Intrinsic::ID IID, unsigned Idx, const APInt &Imm,
103 Type *Ty);
104 bool isLegalMaskedLoad(Type *DataType, int Consecutive);
105 bool isLegalMaskedStore(Type *DataType, int Consecutive);
106
107 /// @}
108};
Chandler Carruth93dcdc42015-01-31 11:17:59 +0000109
110} // end namespace llvm
111
112#endif