blob: 9bef9e80c395ca20cb1d5435ab554c10b9f895e4 [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
Chandler Carruthc956ab662015-02-01 14:22:17 +000036 const X86Subtarget *getST() const { return ST; }
Chandler Carruthc340ca82015-02-01 14:01:15 +000037 const X86TargetLowering *getTLI() const { return TLI; }
38
Chandler Carruth93dcdc42015-01-31 11:17:59 +000039public:
Eric Christophera4e5d3c2015-09-16 23:38:13 +000040 explicit X86TTIImpl(const X86TargetMachine *TM, const Function &F)
Mehdi Amini5010ebf2015-07-09 02:08:42 +000041 : BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)),
42 TLI(ST->getTargetLowering()) {}
Chandler Carruth93dcdc42015-01-31 11:17:59 +000043
Chandler Carruth93dcdc42015-01-31 11:17:59 +000044 /// \name Scalar TTI Implementations
45 /// @{
46 TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth);
47
48 /// @}
49
50 /// \name Vector TTI Implementations
51 /// @{
52
53 unsigned getNumberOfRegisters(bool Vector);
Keno Fischer1ec5dd82017-04-05 20:51:38 +000054 unsigned getRegisterBitWidth(bool Vector) const;
55 unsigned getLoadStoreVecRegBitWidth(unsigned AS) const;
Wei Mi062c7442015-05-06 17:12:25 +000056 unsigned getMaxInterleaveFactor(unsigned VF);
Chandler Carruth93205eb2015-08-05 18:08:10 +000057 int getArithmeticInstrCost(
Chandler Carruth93dcdc42015-01-31 11:17:59 +000058 unsigned Opcode, Type *Ty,
59 TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue,
60 TTI::OperandValueKind Opd2Info = TTI::OK_AnyValue,
61 TTI::OperandValueProperties Opd1PropInfo = TTI::OP_None,
Mohammed Agabaria2c96c432017-01-11 08:23:37 +000062 TTI::OperandValueProperties Opd2PropInfo = TTI::OP_None,
63 ArrayRef<const Value *> Args = ArrayRef<const Value *>());
Chandler Carruth93205eb2015-08-05 18:08:10 +000064 int getShuffleCost(TTI::ShuffleKind Kind, Type *Tp, int Index, Type *SubTp);
Jonas Paulssonfccc7d62017-04-12 11:49:08 +000065 int getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
66 const Instruction *I = nullptr);
67 int getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy,
68 const Instruction *I = nullptr);
Chandler Carruth93205eb2015-08-05 18:08:10 +000069 int getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index);
70 int getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
Jonas Paulssonfccc7d62017-04-12 11:49:08 +000071 unsigned AddressSpace, const Instruction *I = nullptr);
Chandler Carruth93205eb2015-08-05 18:08:10 +000072 int getMaskedMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
73 unsigned AddressSpace);
Elena Demikhovsky54946982015-12-28 20:10:59 +000074 int getGatherScatterOpCost(unsigned Opcode, Type *DataTy, Value *Ptr,
75 bool VariableMask, unsigned Alignment);
Mohammed Agabaria23599ba2017-01-05 14:03:41 +000076 int getAddressComputationCost(Type *PtrTy, ScalarEvolution *SE,
77 const SCEV *Ptr);
Chandler Carruth93dcdc42015-01-31 11:17:59 +000078
Simon Pilgrim14000b32016-05-24 08:17:50 +000079 int getIntrinsicInstrCost(Intrinsic::ID IID, Type *RetTy,
Jonas Paulssona48ea232017-03-14 06:35:36 +000080 ArrayRef<Type *> Tys, FastMathFlags FMF,
81 unsigned ScalarizationCostPassed = UINT_MAX);
Simon Pilgrim14000b32016-05-24 08:17:50 +000082 int getIntrinsicInstrCost(Intrinsic::ID IID, Type *RetTy,
Jonas Paulssona48ea232017-03-14 06:35:36 +000083 ArrayRef<Value *> Args, FastMathFlags FMF,
84 unsigned VF = 1);
Simon Pilgrim14000b32016-05-24 08:17:50 +000085
Chandler Carruth93205eb2015-08-05 18:08:10 +000086 int getReductionCost(unsigned Opcode, Type *Ty, bool IsPairwiseForm);
Chandler Carruth93dcdc42015-01-31 11:17:59 +000087
Elena Demikhovsky21706cb2017-01-02 10:37:52 +000088 int getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy,
89 unsigned Factor, ArrayRef<unsigned> Indices,
90 unsigned Alignment, unsigned AddressSpace);
91 int getInterleavedMemoryOpCostAVX512(unsigned Opcode, Type *VecTy,
92 unsigned Factor, ArrayRef<unsigned> Indices,
93 unsigned Alignment, unsigned AddressSpace);
94
Chandler Carruth93205eb2015-08-05 18:08:10 +000095 int getIntImmCost(int64_t);
Chandler Carruth93dcdc42015-01-31 11:17:59 +000096
Chandler Carruth93205eb2015-08-05 18:08:10 +000097 int getIntImmCost(const APInt &Imm, Type *Ty);
Chandler Carruth93dcdc42015-01-31 11:17:59 +000098
Chandler Carruth93205eb2015-08-05 18:08:10 +000099 int getIntImmCost(unsigned Opcode, unsigned Idx, const APInt &Imm, Type *Ty);
100 int getIntImmCost(Intrinsic::ID IID, unsigned Idx, const APInt &Imm,
101 Type *Ty);
Elena Demikhovsky20662e32015-10-19 07:43:38 +0000102 bool isLegalMaskedLoad(Type *DataType);
103 bool isLegalMaskedStore(Type *DataType);
Elena Demikhovsky09285852015-10-25 15:37:55 +0000104 bool isLegalMaskedGather(Type *DataType);
105 bool isLegalMaskedScatter(Type *DataType);
Eric Christopherd566fb12015-07-29 22:09:48 +0000106 bool areInlineCompatible(const Function *Caller,
107 const Function *Callee) const;
Michael Kupersteinb2443ed2016-10-20 21:04:31 +0000108
109 bool enableInterleavedAccessVectorization();
Elena Demikhovsky54946982015-12-28 20:10:59 +0000110private:
111 int getGSScalarCost(unsigned Opcode, Type *DataTy, bool VariableMask,
112 unsigned Alignment, unsigned AddressSpace);
113 int getGSVectorCost(unsigned Opcode, Type *DataTy, Value *Ptr,
114 unsigned Alignment, unsigned AddressSpace);
Chandler Carruth93dcdc42015-01-31 11:17:59 +0000115
116 /// @}
117};
Chandler Carruth93dcdc42015-01-31 11:17:59 +0000118
119} // end namespace llvm
120
121#endif