2015-01-31 19:17:59 +08:00
|
|
|
//===-- X86TargetTransformInfo.h - X86 specific TTI -------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// \file
|
|
|
|
/// This file a TargetTransformInfo::Concept conforming object specific to the
|
|
|
|
/// X86 target machine. It uses the target's detailed information to
|
|
|
|
/// provide more precise answers to certain TTI queries, while letting the
|
|
|
|
/// target independent and default TTI implementations handle the rest.
|
|
|
|
///
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_LIB_TARGET_X86_X86TARGETTRANSFORMINFO_H
|
|
|
|
#define LLVM_LIB_TARGET_X86_X86TARGETTRANSFORMINFO_H
|
|
|
|
|
|
|
|
#include "X86.h"
|
|
|
|
#include "X86TargetMachine.h"
|
|
|
|
#include "llvm/Analysis/TargetTransformInfo.h"
|
|
|
|
#include "llvm/CodeGen/BasicTTIImpl.h"
|
|
|
|
#include "llvm/Target/TargetLowering.h"
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
class X86TTIImpl : public BasicTTIImplBase<X86TTIImpl> {
|
|
|
|
typedef BasicTTIImplBase<X86TTIImpl> BaseT;
|
|
|
|
typedef TargetTransformInfo TTI;
|
2015-02-01 22:01:15 +08:00
|
|
|
friend BaseT;
|
2015-01-31 19:17:59 +08:00
|
|
|
|
|
|
|
const X86Subtarget *ST;
|
|
|
|
const X86TargetLowering *TLI;
|
|
|
|
|
2015-02-01 22:22:17 +08:00
|
|
|
const X86Subtarget *getST() const { return ST; }
|
2015-02-01 22:01:15 +08:00
|
|
|
const X86TargetLowering *getTLI() const { return TLI; }
|
|
|
|
|
2015-01-31 19:17:59 +08:00
|
|
|
public:
|
2015-09-17 07:38:13 +08:00
|
|
|
explicit X86TTIImpl(const X86TargetMachine *TM, const Function &F)
|
2015-07-09 10:08:42 +08:00
|
|
|
: BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)),
|
|
|
|
TLI(ST->getTargetLowering()) {}
|
2015-01-31 19:17:59 +08:00
|
|
|
|
|
|
|
/// \name Scalar TTI Implementations
|
|
|
|
/// @{
|
|
|
|
TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth);
|
|
|
|
|
|
|
|
/// @}
|
|
|
|
|
|
|
|
/// \name Vector TTI Implementations
|
|
|
|
/// @{
|
|
|
|
|
|
|
|
unsigned getNumberOfRegisters(bool Vector);
|
2017-04-06 04:51:38 +08:00
|
|
|
unsigned getRegisterBitWidth(bool Vector) const;
|
|
|
|
unsigned getLoadStoreVecRegBitWidth(unsigned AS) const;
|
2015-05-07 01:12:25 +08:00
|
|
|
unsigned getMaxInterleaveFactor(unsigned VF);
|
2015-08-06 02:08:10 +08:00
|
|
|
int getArithmeticInstrCost(
|
2015-01-31 19:17:59 +08:00
|
|
|
unsigned Opcode, Type *Ty,
|
|
|
|
TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue,
|
|
|
|
TTI::OperandValueKind Opd2Info = TTI::OK_AnyValue,
|
|
|
|
TTI::OperandValueProperties Opd1PropInfo = TTI::OP_None,
|
[X86] updating TTI costs for arithmetic instructions on X86\SLM arch.
updated instructions:
pmulld, pmullw, pmulhw, mulsd, mulps, mulpd, divss, divps, divsd, divpd, addpd and subpd.
special optimization case which replaces pmulld with pmullw\pmulhw\pshuf seq.
In case if the real operands bitwidth <= 16.
Differential Revision: https://reviews.llvm.org/D28104
llvm-svn: 291657
2017-01-11 16:23:37 +08:00
|
|
|
TTI::OperandValueProperties Opd2PropInfo = TTI::OP_None,
|
|
|
|
ArrayRef<const Value *> Args = ArrayRef<const Value *>());
|
2015-08-06 02:08:10 +08:00
|
|
|
int getShuffleCost(TTI::ShuffleKind Kind, Type *Tp, int Index, Type *SubTp);
|
2017-04-12 19:49:08 +08:00
|
|
|
int getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
|
|
|
|
const Instruction *I = nullptr);
|
|
|
|
int getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy,
|
|
|
|
const Instruction *I = nullptr);
|
2015-08-06 02:08:10 +08:00
|
|
|
int getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index);
|
|
|
|
int getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
|
2017-04-12 19:49:08 +08:00
|
|
|
unsigned AddressSpace, const Instruction *I = nullptr);
|
2015-08-06 02:08:10 +08:00
|
|
|
int getMaskedMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment,
|
|
|
|
unsigned AddressSpace);
|
2015-12-29 04:10:59 +08:00
|
|
|
int getGatherScatterOpCost(unsigned Opcode, Type *DataTy, Value *Ptr,
|
|
|
|
bool VariableMask, unsigned Alignment);
|
2017-01-05 22:03:41 +08:00
|
|
|
int getAddressComputationCost(Type *PtrTy, ScalarEvolution *SE,
|
|
|
|
const SCEV *Ptr);
|
2015-01-31 19:17:59 +08:00
|
|
|
|
2017-06-07 00:45:25 +08:00
|
|
|
unsigned getAtomicMemIntrinsicMaxElementSize() const;
|
|
|
|
|
2016-05-24 16:17:50 +08:00
|
|
|
int getIntrinsicInstrCost(Intrinsic::ID IID, Type *RetTy,
|
2017-03-14 14:35:36 +08:00
|
|
|
ArrayRef<Type *> Tys, FastMathFlags FMF,
|
|
|
|
unsigned ScalarizationCostPassed = UINT_MAX);
|
2016-05-24 16:17:50 +08:00
|
|
|
int getIntrinsicInstrCost(Intrinsic::ID IID, Type *RetTy,
|
2017-03-14 14:35:36 +08:00
|
|
|
ArrayRef<Value *> Args, FastMathFlags FMF,
|
|
|
|
unsigned VF = 1);
|
2016-05-24 16:17:50 +08:00
|
|
|
|
2017-07-31 22:19:32 +08:00
|
|
|
int getArithmeticReductionCost(unsigned Opcode, Type *Ty,
|
|
|
|
bool IsPairwiseForm);
|
2015-01-31 19:17:59 +08:00
|
|
|
|
2017-01-02 18:37:52 +08:00
|
|
|
int getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy,
|
|
|
|
unsigned Factor, ArrayRef<unsigned> Indices,
|
|
|
|
unsigned Alignment, unsigned AddressSpace);
|
|
|
|
int getInterleavedMemoryOpCostAVX512(unsigned Opcode, Type *VecTy,
|
|
|
|
unsigned Factor, ArrayRef<unsigned> Indices,
|
|
|
|
unsigned Alignment, unsigned AddressSpace);
|
2017-06-25 16:26:25 +08:00
|
|
|
int getInterleavedMemoryOpCostAVX2(unsigned Opcode, Type *VecTy,
|
|
|
|
unsigned Factor, ArrayRef<unsigned> Indices,
|
|
|
|
unsigned Alignment, unsigned AddressSpace);
|
2017-01-02 18:37:52 +08:00
|
|
|
|
2015-08-06 02:08:10 +08:00
|
|
|
int getIntImmCost(int64_t);
|
2015-01-31 19:17:59 +08:00
|
|
|
|
2015-08-06 02:08:10 +08:00
|
|
|
int getIntImmCost(const APInt &Imm, Type *Ty);
|
2015-01-31 19:17:59 +08:00
|
|
|
|
2017-08-20 20:34:29 +08:00
|
|
|
unsigned getUserCost(const User *U, ArrayRef<const Value *> Operands);
|
|
|
|
|
2015-08-06 02:08:10 +08:00
|
|
|
int getIntImmCost(unsigned Opcode, unsigned Idx, const APInt &Imm, Type *Ty);
|
|
|
|
int getIntImmCost(Intrinsic::ID IID, unsigned Idx, const APInt &Imm,
|
|
|
|
Type *Ty);
|
2017-08-08 03:56:34 +08:00
|
|
|
bool isLSRCostLess(TargetTransformInfo::LSRCost &C1,
|
|
|
|
TargetTransformInfo::LSRCost &C2);
|
2015-10-19 15:43:38 +08:00
|
|
|
bool isLegalMaskedLoad(Type *DataType);
|
|
|
|
bool isLegalMaskedStore(Type *DataType);
|
2015-10-25 23:37:55 +08:00
|
|
|
bool isLegalMaskedGather(Type *DataType);
|
|
|
|
bool isLegalMaskedScatter(Type *DataType);
|
2015-07-30 06:09:48 +08:00
|
|
|
bool areInlineCompatible(const Function *Caller,
|
|
|
|
const Function *Callee) const;
|
2017-06-20 23:58:30 +08:00
|
|
|
bool expandMemCmp(Instruction *I, unsigned &MaxLoadSize);
|
2016-10-21 05:04:31 +08:00
|
|
|
bool enableInterleavedAccessVectorization();
|
2015-12-29 04:10:59 +08:00
|
|
|
private:
|
|
|
|
int getGSScalarCost(unsigned Opcode, Type *DataTy, bool VariableMask,
|
|
|
|
unsigned Alignment, unsigned AddressSpace);
|
|
|
|
int getGSVectorCost(unsigned Opcode, Type *DataTy, Value *Ptr,
|
|
|
|
unsigned Alignment, unsigned AddressSpace);
|
2015-01-31 19:17:59 +08:00
|
|
|
|
|
|
|
/// @}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif
|