LLVM  4.0.0
X86TargetTransformInfo.h
Go to the documentation of this file.
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"
25 
26 namespace llvm {
27 
28 class X86TTIImpl : public BasicTTIImplBase<X86TTIImpl> {
30  typedef TargetTransformInfo TTI;
31  friend BaseT;
32 
33  const X86Subtarget *ST;
34  const X86TargetLowering *TLI;
35 
36  int getScalarizationOverhead(Type *Ty, bool Insert, bool Extract);
37 
38  const X86Subtarget *getST() const { return ST; }
39  const X86TargetLowering *getTLI() const { return TLI; }
40 
41 public:
42  explicit X86TTIImpl(const X86TargetMachine *TM, const Function &F)
43  : BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)),
44  TLI(ST->getTargetLowering()) {}
45 
46  /// \name Scalar TTI Implementations
47  /// @{
48  TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth);
49 
50  /// @}
51 
52  /// \name Vector TTI Implementations
53  /// @{
54 
55  unsigned getNumberOfRegisters(bool Vector);
56  unsigned getRegisterBitWidth(bool Vector);
57  unsigned getMaxInterleaveFactor(unsigned VF);
59  unsigned Opcode, Type *Ty,
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);
76  const SCEV *Ptr);
77 
82 
83  int getReductionCost(unsigned Opcode, Type *Ty, bool IsPairwiseForm);
84 
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);
91 
92  int getIntImmCost(int64_t);
93 
94  int getIntImmCost(const APInt &Imm, Type *Ty);
95 
96  int getIntImmCost(unsigned Opcode, unsigned Idx, const APInt &Imm, Type *Ty);
97  int getIntImmCost(Intrinsic::ID IID, unsigned Idx, const APInt &Imm,
98  Type *Ty);
103  bool areInlineCompatible(const Function *Caller,
104  const Function *Callee) const;
105 
107 private:
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);
112 
113  /// @}
114 };
115 
116 } // end namespace llvm
117 
118 #endif
int getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index)
int getGatherScatterOpCost(unsigned Opcode, Type *DataTy, Value *Ptr, bool VariableMask, unsigned Alignment)
Calculate the cost of Gather / Scatter operation.
int getIntrinsicInstrCost(Intrinsic::ID IID, Type *RetTy, ArrayRef< Type * > Tys, FastMathFlags FMF)
The main scalar evolution driver.
int getArithmeticInstrCost(unsigned Opcode, Type *Ty, TTI::OperandValueKind Opd1Info=TTI::OK_AnyValue, TTI::OperandValueKind Opd2Info=TTI::OK_AnyValue, TTI::OperandValueProperties Opd1PropInfo=TTI::OP_None, TTI::OperandValueProperties Opd2PropInfo=TTI::OP_None, ArrayRef< const Value * > Args=ArrayRef< const Value * >())
bool isLegalMaskedScatter(Type *DataType)
Base class which can be used to help build a TTI implementation.
Definition: BasicTTIImpl.h:40
int getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef< unsigned > Indices, unsigned Alignment, unsigned AddressSpace)
int getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment, unsigned AddressSpace)
unsigned getNumberOfRegisters(bool Vector)
unsigned getMaxInterleaveFactor(unsigned VF)
bool isLegalMaskedStore(Type *DataType)
#define F(x, y, z)
Definition: MD5.cpp:51
PopcntSupportKind
Flags indicating the kind of support for population count.
int getReductionCost(unsigned Opcode, Type *Ty, bool IsPairwiseForm)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:33
int getAddressComputationCost(Type *PtrTy, ScalarEvolution *SE, const SCEV *Ptr)
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
bool isLegalMaskedGather(Type *DataType)
bool isLegalMaskedLoad(Type *DataType)
int getMaskedMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment, unsigned AddressSpace)
This file provides a helper that implements much of the TTI interface in terms of the target-independ...
bool areInlineCompatible(const Function *Caller, const Function *Callee) const
int getShuffleCost(TTI::ShuffleKind Kind, Type *Tp, int Index, Type *SubTp)
TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth)
OperandValueProperties
Additional properties of an operand's values.
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
AddressSpace
Definition: NVPTXBaseInfo.h:22
Class for arbitrary precision integers.
Definition: APInt.h:77
int getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src)
unsigned getRegisterBitWidth(bool Vector)
const DataLayout & getDataLayout() const
This class represents an analyzed expression in the program.
const unsigned Kind
int getInterleavedMemoryOpCostAVX512(unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef< unsigned > Indices, unsigned Alignment, unsigned AddressSpace)
LLVM Value Representation.
Definition: Value.h:71
static const Function * getParent(const Value *V)
int getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy)
Convenience struct for specifying and reasoning about fast-math flags.
Definition: Operator.h:168
OperandValueKind
Additional information about an operand's possible values.
This pass exposes codegen information to IR-level passes.
int * Ptr
X86TTIImpl(const X86TargetMachine *TM, const Function &F)
int getIntImmCost(int64_t)
Calculate the cost of materializing a 64-bit value.
This file describes how to lower LLVM code to machine code.
ShuffleKind
The various kinds of shuffle patterns for vector queries.