blob: 5ddde2a45a570961bffdaa9678be1555a2b49711 [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 Carruth93205eb2015-08-05 18:08:10 +000036 int getScalarizationOverhead(Type *Ty, bool Insert, bool Extract);
Chandler Carruth93dcdc42015-01-31 11:17:59 +000037
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:
Eric Christophera4e5d3c2015-09-16 23:38:13 +000042 explicit X86TTIImpl(const X86TargetMachine *TM, const Function &F)
Mehdi Amini5010ebf2015-07-09 02:08:42 +000043 : BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)),
44 TLI(ST->getTargetLowering()) {}
Chandler Carruth93dcdc42015-01-31 11:17:59 +000045
46 // Provide value semantics. MSVC requires that we spell all of these out.
47 X86TTIImpl(const X86TTIImpl &Arg)
Chandler Carruthc956ab662015-02-01 14:22:17 +000048 : BaseT(static_cast<const BaseT &>(Arg)), ST(Arg.ST), TLI(Arg.TLI) {}
Chandler Carruth93dcdc42015-01-31 11:17:59 +000049 X86TTIImpl(X86TTIImpl &&Arg)
Chandler Carruthc956ab662015-02-01 14:22:17 +000050 : BaseT(std::move(static_cast<BaseT &>(Arg))), ST(std::move(Arg.ST)),
51 TLI(std::move(Arg.TLI)) {}
Chandler Carruth93dcdc42015-01-31 11:17:59 +000052
53 /// \name Scalar TTI Implementations
54 /// @{
55 TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth);
56
57 /// @}
58
59 /// \name Vector TTI Implementations
60 /// @{
61
62 unsigned getNumberOfRegisters(bool Vector);
63 unsigned getRegisterBitWidth(bool Vector);
Wei Mi062c7442015-05-06 17:12:25 +000064 unsigned getMaxInterleaveFactor(unsigned VF);
Chandler Carruth93205eb2015-08-05 18:08:10 +000065 int getArithmeticInstrCost(
Chandler Carruth93dcdc42015-01-31 11:17:59 +000066 unsigned Opcode, Type *Ty,
67 TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue,
68 TTI::OperandValueKind Opd2Info = TTI::OK_AnyValue,
69 TTI::OperandValueProperties Opd1PropInfo = TTI::OP_None,
70 TTI::OperandValueProperties Opd2PropInfo = TTI::OP_None);
Chandler Carruth93205eb2015-08-05 18:08:10 +000071 int getShuffleCost(TTI::ShuffleKind Kind, Type *Tp, int Index, Type *SubTp);
72 int getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src);
73 int getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy);
74 int getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index);
75 int getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
76 unsigned AddressSpace);
77 int getMaskedMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
78 unsigned AddressSpace);
Chandler Carruth93dcdc42015-01-31 11:17:59 +000079
Chandler Carruth93205eb2015-08-05 18:08:10 +000080 int getAddressComputationCost(Type *PtrTy, bool IsComplex);
Chandler Carruth93dcdc42015-01-31 11:17:59 +000081
Chandler Carruth93205eb2015-08-05 18:08:10 +000082 int getReductionCost(unsigned Opcode, Type *Ty, bool IsPairwiseForm);
Chandler Carruth93dcdc42015-01-31 11:17:59 +000083
Chandler Carruth93205eb2015-08-05 18:08:10 +000084 int getIntImmCost(int64_t);
Chandler Carruth93dcdc42015-01-31 11:17:59 +000085
Chandler Carruth93205eb2015-08-05 18:08:10 +000086 int getIntImmCost(const APInt &Imm, Type *Ty);
Chandler Carruth93dcdc42015-01-31 11:17:59 +000087
Chandler Carruth93205eb2015-08-05 18:08:10 +000088 int getIntImmCost(unsigned Opcode, unsigned Idx, const APInt &Imm, Type *Ty);
89 int getIntImmCost(Intrinsic::ID IID, unsigned Idx, const APInt &Imm,
90 Type *Ty);
Elena Demikhovsky20662e32015-10-19 07:43:38 +000091 bool isLegalMaskedLoad(Type *DataType);
92 bool isLegalMaskedStore(Type *DataType);
Eric Christopherd566fb12015-07-29 22:09:48 +000093 bool areInlineCompatible(const Function *Caller,
94 const Function *Callee) const;
Chandler Carruth93dcdc42015-01-31 11:17:59 +000095
96 /// @}
97};
Chandler Carruth93dcdc42015-01-31 11:17:59 +000098
99} // end namespace llvm
100
101#endif